Saver

One of the most popular problem of state is saving it. On Frontend it is saving to any Storage or sending data to server. So I decided to offer you an API which allows to control saving of Store.

export interface SaverOptions<State extends Record<string, unknown>> {
    /**
     * Select one of the default or create your custom Saver
     */
    saver: {
        new (store: ProtoStore<State>): Saver<State>;
    };
    /**
     * Which keys of State would be saved
     */
    keysToSave?: (keyof State)[];
    /**
     * Changing which keys of the State would be a trigger of saving
     */
    keysBySave?: (keyof State)[];
    /**
     * Project: Saver for separate entity in State
     * Does not work yet!
     */
    saverByKey?: SaverByKey<State>;
}

By default there is available savers like LocalStorageSaver.

Last updated