Interface WritableSignal<T, U>

Represents a store that implements both ReadableSignal and Writable. This is the type of objects returned by writable.

interface WritableSignal<T, U> {
    [observable](): Readable<T>;
    get(): T;
    set(value: U): void;
    subscribe(subscriber: Subscriber<T>): UnsubscribeFunction & UnsubscribeObject;
    update(updater: Updater<T, U>): void;
    (): T;
}

Type Parameters

  • T
  • U = T

Hierarchy (view full)

  • Returns the value of the store.

    Returns T

Methods

  • Replaces store's state with the provided value.

    Parameters

    • value: U

      value to be used as the new state of a store.

    Returns void

  • Updates store's state by using an Updater function.

    Parameters

    • updater: Updater<T, U>

      a function that takes the current state as an argument and returns the new state.

    Returns void