Interface Persist<T>

Source
Expand description

A cell that also persists its value

interface Persist<T> {
    clear(): void;
    disable(): void;
    get(): T;
    init(initial?: T): T;
    set(value: T): void;
    subscribe(
        callback: (value: T) => void,
        notifyImmediately?: boolean,
    ): () => void;
}

Methods§

Source§

clear(): void

Clear the value from the storage

Source§

disable(): void

Clear the value and disable the persistence

Source§

get(): T

Source§

init(initial?: T): T

Load the value initially, and notify all the current subscribers

Optionally, you can pass an initial value to override the current value

Source§

set(value: T): void

Source§

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