Interface StateContainerPersistence<TState>

Type Parameters

  • TState extends Object

Hierarchy

  • StateContainerPersistence

Properties

attributes: (keyof TState)[]

List of attributes to persist

converter?: ((args) => Partial<TState>)

Type declaration

    • (args): Partial<TState>
    • Optional converter function to convert persisted state. This is useful when persisted state should be migrated to new version.

      Rules of persistence conversion:

      • it is the user responsibility to provide and implement a converter function
      • state is persisted in so called "envelope" (see persistence-envelope.ts)

      The converter function inside should compare version attribute.

      Parameters

      Returns Partial<TState>

getEnvelope: ((key) => PersistenceEnvelope)

Type declaration

    • (key): PersistenceEnvelope
    • Mandatory function - provided externally - to read persisted state envelope from the persistence target (local storage, etc.) under a given key

      For the sake of simplicity, use synchronous get from local-storage

      Parameters

      • key: string

      Returns PersistenceEnvelope

getKey?: ((args) => string)

Type declaration

    • (args): string
    • Optional function to generate a key in getEnvelope and setEnvelope functions.

      Parameters

      • args: {
            containerId: string;
            prefix?: string;
        }
        • containerId: string
        • Optional prefix?: string

      Returns string

prefix?: string

State-container specific prefix name for a persistence entry in a key-value store. For now, the only key-value store supported is the local-storage.

Typically, the fraction of state will get persisted under the App.Container.${containerId} key. This prefix can be, however, changed

setEnvelope: ((key, envelope) => void)

Type declaration

    • (key, envelope): void
    • Mandatory function to write persisted state envelope to the persistence target (local storage, etc.) under a given key

      For the sake of simplicity, use synchronous set from local-storage npm library

      Parameters

      Returns void

version: string

Version of persisted state

Generated using TypeDoc