UNPKG

atombeak

Version:

Create asynchronous atomic functions!

29 lines (28 loc) 1.41 kB
import { LogItem } from './LogItem'; export declare const APPEND_SUCCESS: 'APPEND_SUCCESS'; export declare type AppendSucces<Outer, Action> = Readonly<{ type: typeof APPEND_SUCCESS; log: Log<Outer, Action>; }>; export declare function appendSuccess<Outer, Action>(log: Log<Outer, Action>): AppendSucces<Outer, Action>; export declare const RESTART_WITH_OUTER: 'RESTART_WITH_OUTER'; export declare type RestartWithOuter<Outer> = Readonly<{ type: typeof RESTART_WITH_OUTER; outer: Outer; }>; export declare function restartWithOuter<Outer>(outer: Outer): RestartWithOuter<Outer>; export declare type AppendResult<Outer, Action> = AppendSucces<Outer, Action> | RestartWithOuter<Outer>; export declare class Log<Outer, Action> { readonly itemsReversed: LogItem<Outer, any, Action>[]; static create<Outer, Action>(originalOuter: Outer): Log<Outer, Action>; constructor(itemsReversed: LogItem<Outer, any, Action>[]); read<Inner>(id: string, reader: (outer: Outer) => Inner): [Inner, Log<Outer, Action>]; private findMostRecentReadOrWrite; private fromState; write<Inner>(id: string, inner: Inner, action: Action): Log<Outer, Action>; private appendReadOrWrite; isConsistentWithOuter(outer: Outer): boolean; getActions(): Action[]; appendState(outer: Outer): AppendResult<Outer, Action>; appendStates(...outers: Outer[]): AppendResult<Outer, Action>; }