whenever
Category Lifecycle
Shorthand for running a callback when a dependency is truthy.
It can also take an array of dependencies, in which case it will run if all dependencies are truthy.
Usage
Type definitions
import type { Getter } from '../../__internal__/types.js';
type WheneverOptions = {
/**
* Whether to run the effect on mount or not.
* @default true
*/
runOnMount?: boolean;
};
/**
* Triggers a callback when the dependency is `true`.
* @param dep The dependency to watch.
* @param fn The callback to trigger when the dependency is `true`.
* @param options Additional options to customize the behavior.
* @see https://svelte-librarian.github.io/sv-use/docs/core/lifecycle/whenever
*/
export declare function whenever(dep: Getter<boolean>, fn: () => void, options?: WheneverOptions): void;
/**
* Triggers a callback when the dependencies are `true`.
* @param deps The dependencies to watch.
* @param fn The callback to trigger when the dependencies are `true`.
* @param options Additional options to customize the behavior.
* @see https://svelte-librarian.github.io/sv-use/docs/core/lifecycle/whenever
*/
export declare function whenever(deps: Array<Getter<boolean>>, fn: () => void, options?: WheneverOptions): void;
export {};