• A convenience function to create Writable store instances.

    Type Parameters

    • T

    Parameters

    • value: T

      initial value of a new writable store.

    • options: StoreOptions<T> | OnUseFn<T> = {}

      Either an object with store options, or directly the onUse function.

      The onUse function is a function called when the number of subscribers changes from 0 to 1 (but not called when the number of subscribers changes from 1 to 2, ...).

      If a function is returned, it will be called when the number of subscribers changes from 1 to 0.

    Returns WritableSignal<T>

    Example

    const x = writable(0);

    x.update(v => v + 1); // increment
    x.set(0); // reset back to the default value

Generated using TypeDoc