Vinyl
    Preparing search index...

    Interface PersistentItemOptions<T, FormatType>

    Configuration for PersistentItemImpl These values will not be accessed until the persistent item is first used.

    interface PersistentItemOptions<T, FormatType> {
        defaultValue: T;
        deserialize: (value: FormatType) => T;
        key: string;
        persistence:
            | KeyValuePersistence<FormatType>
            | (() => KeyValuePersistence<FormatType>);
        serialize: (value: T) => FormatType;
        validator?: Maybe<(input: unknown) => asserts input is T>;
    }

    Type Parameters

    • T
    • FormatType
    Index

    Properties

    defaultValue: T

    The default to use when the key is not present or deserialization fails.

    deserialize: (value: FormatType) => T

    Deserializes value into the output value.

    key: string

    The key to use in the Persistence layer.

    persistence:
        | KeyValuePersistence<FormatType>
        | (() => KeyValuePersistence<FormatType>)

    The key/value persistence raw data provider.

    Provides the KeyValuePersistence controller. Can be a method to lazily provide the controller, will be invoked once on first access.

    serialize: (value: T) => FormatType

    Serializes the value for persistence.

    validator?: Maybe<(input: unknown) => asserts input is T>

    If provided, will be invoked on the persisted value.