UNPKG

@state-sync/redux-path-reducer

Version:
57 lines (56 loc) 2.29 kB
import { PatchAreaError, PatchAreaEvent, PatchAreaResponse, SignalError, SignalResponse, SubscribeAreaError, SubscribeAreaResponse, UnsubscribeAreaResponse } from './Events'; import { ISyncArea } from './ISyncArea'; import SyncAreaHelper from './SyncAreaHelper'; export declare class SyncArea implements ISyncArea { private helper; name: string; private subscriptionsCount; /** * Configuration retrieved from server in a process of subscription */ private config; private initialState; private subscribed; private patchQueue; private invocations; /** * Local copy of state, updated by reducer, used by actions to get current values */ private local; private ready; private modelVersion; constructor(name: string, initialState: any, helper: SyncAreaHelper); isReady(): boolean; init(): void; wrap(reducer: any): any; model(): any; select(path: string): any; /** * Invoke when connection is ready */ onReady(): void; subscribe(): Promise<number>; private doSubscription(); unsubscribe(): void; signal(command: string, parameters?: any): Promise<number>; onSignalResponse(event: SignalResponse): void; onSignalError(event: SignalError): void; onSubscribe(event: SubscribeAreaResponse): void; onUnsubscribe(event: UnsubscribeAreaResponse): void; dispatchSyncPatch(event: PatchAreaEvent): void; onPatchResponse(event: PatchAreaResponse): void; private pushPatches(); onServerPatch(event: PatchAreaEvent): void; onPatchAreaError(event: PatchAreaError): void; onSubscribeError(event: SubscribeAreaError): void; actionArrayInsertByKey(path: string, item: any, keyField: string): void; actionArrayReplaceByKey(path: string, data: any, keyField: string): void; actionArrayRemoveByKey(path: string, keyField: string, value: any): void; actionArrayRemoveByIndex(path: string, index: number): void; actionReplace(path: string, value: any): void; actionRemove(path: string, condition?: (item: any) => boolean): void; actionReduce<T>(path: string, reducer: (state: T) => T): void; actionToggle(path: string): void; private reduce(state, action, ext, reducer); private detectChanges(from, to); }