Interface WritableFn<T, Args, R>
interface WritableFn<T, Args extends unknown[], R = void> {
set(this: void, value: T): void;
subscribe(
this: void,
run: Subscriber<T>,
invalidate?: Invalidator<T>,
): Unsubscriber;
update(this: void, updater: Updater<T>): void;
(...args: Args): R;
}
set(this: void, value: T): void;
subscribe(
this: void,
run: Subscriber<T>,
invalidate?: Invalidator<T>,
): Unsubscriber;
update(this: void, updater: Updater<T>): void;
(...args: Args): R;
}
Type Parameters
- T
The type of the value stored in the writable store.
- Args extends unknown[]
The tuple of argument types accepted by the function.
- R = void
The return type of the function.
Hierarchy
- Writable<T>
- WritableFn (View Summary)
Methods
set
subscribe
-
Subscribe on value changes.
Parameters
- this: void
- run: Subscriber<T>
subscription callback
Optionalinvalidate: Invalidator<T>cleanup callback
Returns Unsubscriber
Combines a writable Svelte store with a callable function. This type allows a writable store to also act as a function enabling flexible reactive behavior.