Practic BUI (Base UI) - v1.0.0
    Preparing search index...

    Type Alias PersistedState<T>

    PersistedState: PersistLocation<T> & {
        get: () => T;
        ready: () => Promise<void>;
        set: (action: PersistSetAction<T>) => void;
        store: () => PersistKeyStore;
        subscribe: (listener: () => void) => () => void;
    }

    One persisted value, declared once and shared by components and plain functions. Components read it with usePersistedState(state); code outside React calls get, set and subscribe, which always see the current value.

    Type Parameters

    • T

    Type Declaration

    • get: () => T

      The current value: the stored one, or initialValue until one is stored.

    • ready: () => Promise<void>

      Resolves once stored values have loaded: at once for localStorage, later for IndexedDB.

    • set: (action: PersistSetAction<T>) => void

      Stores a value or the result of an updater, like React's useState setter.

    • store: () => PersistKeyStore

      The store holding the value: the layer's store for its key, or its own memory store without an attribute.

    • subscribe: (listener: () => void) => () => void

      Calls the listener after every change to the value's key; returns the function that stops it.