import { BehaviorSubject } from 'rxjs'; import { IStore } from './IStore'; export declare type IStateUpdaterFunc = (state: State) => Partial; export declare type IStateUpdater = Partial | IStateUpdaterFunc; /** * Prostore which uses BehaviorSubject to hold its state. * It mimics the React class component state management. * You can use setState to change part of the state of the store. * * It performs synchronous state updates which means that two consequent calls to setState * will result in dispatching two store updates. */ export declare class BehaviorStore implements IStore { state$: BehaviorSubject; get state(): State; constructor(initialState: State); /** * This callback is called when the first subscriber subscribes to this store. * It may be called multiple times during the lifetime of the store. * You can use it to perform side-effects like subscribing to other * observables. */ onSubscribe(): void; /** * This callback is called when the last subscriber unsubscribes from this store. * It may be called multiple times during the lifetime of the store. * You can use it to cleanup side-effects created during onSubscribe. */ onUnsubscribe(): void; /** * Update part of the store state. * * @param stateUpdate - object containing partial state update or updater function. * If the function is provided, it is called with the current state and should return the partial state update */ setState(stateUpdate: IStateUpdater): void; _applyStateUpdater(state: State, stateUpdate: IStateUpdater): State; }