Interface PersistConstructor<T>

Source
Expand description

Args for creating a persisted cell

interface PersistConstructor<T> {
    initial: T;
    key: string;
    storage: PersistStorage;
    deserialize?(value: string): T | null;
    serialize?(value: T): string;
}

Properties§

§initial: T

Initial value

§key: string

The key to use in the storage

§storage: PersistStorage

The web storage to use

Methods§

Source§

deserialize?(value: string): T | null

Deserialize the value from the storage

By default, it will use JSON.parse wrapped with try-catch

Source§

serialize?(value: T): string

Serialize the value to store in the storage

By default, it will use JSON.stringify