Interface Cell<T>

Source
Expand description

See cell

interface Cell<T> {
    get(): T;
    set(value: T): void;
    subscribe(
        callback: (value: T) => void,
        notifyImmediately?: boolean,
    ): () => void;
}

Methods§

Source§

get(): T

Get the current value

Source§

set(value: T): void

Set the value and triggers subscribers if the new value is not the same reference (compared with ===)

Source§

subscribe(callback: (value: T) => void, notifyImmediately?: boolean): () => void

Add a subscriber. Returns a function to unsubscribe