tryOnMount

Safe onMount. Call onMount() if it's inside a component lifecycle, if not, run just call the function.

Usage

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

tryOnMount(() => {})

Type Declarations

/**
 * Call `onMount()` if it's inside a component lifecycle, if not, run just call the function.
 *
 * @param fn
 */
export declare function tryOnMount(fn: Fn | (() => Fn)): void

Source

SourceDocs