import { PersistenceConfig } from './persistor'; export type Notify = (value: V) => void; export type Unsubscribe = () => void; export type Action = (state: T) => T | Promise; interface getStateFunc { (): T; (safe: true): Promise; } /** * Sovran State Store */ export interface Store { /** * Register a callback for changes to the store * @param {Notify} callback - callback to be called when the store changes * @returns {Unsubscribe} - function to unsubscribe from the store */ subscribe: (callback: Notify) => Unsubscribe; /** * Dispatch an action to update the store values * @param {T | Promise} action - action to dispatch * @returns {T} new state */ dispatch: (action: Action) => Promise; /** * Get the current state of the store * @param {boolean} safe - if true it will execute the get async in the queue of the reducers guaranteeing that all the actions are executed before retrieving state * @returns {T | Promise} state, or a promise for the state if executed async in the queue */ getState: getStateFunc; } /** * Creates a simple state store. * @param initialState initial store values * @param storeId store instance id * @returns {Store} object */ export interface StoreConfig { /** * Persistence configuration */ persist?: PersistenceConfig; } /** * Creates a sovran state management store * @param initialState initial state of the store * @param config configuration options * @returns Sovran Store object */ export declare const createStore: (initialState: T, config?: StoreConfig) => Store; export {}; //# sourceMappingURL=store.d.ts.map