import StoreLogger, { ServerFrameworkType } from './store-logger'; import * as Redux from 'redux'; export type IBranch = (fn: (reducer: Redux.Reducer, ...middleware: Redux.Middleware[]) => void) => void; export type ReduxStore = Redux.Store; export interface IBranches { [key: string]: IBranch; } /** * Dispatch an action * * @param action * - single action * - array of actions or promises (nesting supported) * - promise resolved with any of the above */ export declare const dispatch: (storeDispatch: any) => (action: any) => any; /** * Same as dispatch() but also logs the action to server */ export declare const dispatchAndLog: (storeDispatch: any) => (action: T) => Promise; /** * Same as dispatchAndLog() but dispatching is deferred until after logging the action to server */ export declare const logAndDispatch: (storeDispatch: any) => (action: T) => Promise; export interface StoreOptions { logUrl?: string; server?: ServerFrameworkType; } export declare const sessionId: any; export declare class Store { private readonly store; logger: StoreLogger; private readonly options; constructor(branches: IBranches, options?: StoreOptions); /** * Dispatch an action * * @param action * - single action * - array of actions or promises (nesting supported) * - promise resolved with any of the above */ dispatch: ReturnType; /** * Same as dispatch() but also logs the action to server */ dispatchAndLog: ReturnType; /** * Same as dispatchAndLog() but dispatching is deferred until after logging the action to server */ logAndDispatch: ReturnType; /** * Returns store's state * * @param branch e.g. "notebook.folders" */ getState(branch?: any): S; /** * Subscribe to changes in a particular branch in the store * The handler will be executed immediately and every time the branch state reference changes * * @param branch e.g. "notebook.folders" * @param fn handler */ subscribe(branch: string, fn: (state: any, store?: any) => void, scope: any): Function; getReduxStore(): ReduxStore; } /** * Create a new store * * @param branches branches to init in the new store */ export default function create(branches: IBranches, options?: StoreOptions): Store;