tryOnDestroy

Safe onDestroy. Call onDestroy() if it's inside a component lifecycle, if not, do nothing.

Usage

import { tryOnDestroy } from '@svelte-use/core'

tryOnDestroy(() => {})

Type Declarations

/**
 * Call onDestroy() if it's inside a component lifecycle, if not, do nothing.
 *
 * @param fn
 */
export declare function tryOnDestroy(fn: Fn): void

Source

SourceDocs