import { EventEmitter, IEvent, TListener } from './EventEmitter'; import { afterRelease } from './afterRelease'; import { autorun } from './autorun'; import { reaction } from './reaction'; import { release } from './release'; export type CellValue = T extends Cell ? U : T; export interface ICellChangeEvent extends IEvent<{ value: CellValue; prevValue: CellValue; }, Target> { type: typeof Cell.EVENT_CHANGE; } export interface ICellErrorEvent extends IEvent<{ error: Error; }, Target> { type: typeof Cell.EVENT_ERROR; } export type TCellEvent = ICellChangeEvent | ICellErrorEvent; export type TCellChangeEventListener = TListener, Context>; export type TCellErrorEventListener = TListener, Context>; export type TCellEventListener = TCellChangeEventListener | TCellErrorEventListener; export interface ICellListeners { [Cell.EVENT_CHANGE]?: TCellChangeEventListener; [Cell.EVENT_ERROR]?: TCellErrorEventListener; } export type TCellPull = (this: Context, cell: Cell, value: Value | undefined) => Value; export type TCellPut = (this: Context, cell: Cell, nextValue: Value, value: Value | undefined) => void; export interface ICellOptions { context?: Context; meta?: Meta; writable?: boolean; pull?: TCellPull; dependencyFilter?: (dep: Cell) => any; validate?: (nextValue: Value, value: Value | undefined) => void; put?: TCellPut; compareValues?: (nextValue: Value, value: Value | undefined) => boolean; reap?: (this: Context) => void; value?: Value; onChange?: TCellChangeEventListener>; onError?: TCellErrorEventListener>; } export interface IDependencyList { cell: Cell; _nextDependency: IDependencyList | null; state: number; } export interface IDependentList { cell: Cell; _nextDependent: IDependentList | null; prevDependents: IDependentList | null; } export declare enum CellState { ACTUAL = "actual", DIRTY = "dirty", CHECK = "check" } export declare const Cell_CommonState: { pendingCells: Array; pendingCellsIndex: number; currentCell: Cell | null; lastUpdateId: number; afterRelease: Array | null; transactionStates: Map | null; inUntrackedCounter: number; inTrackedCounter: number; }; export declare class Cell extends EventEmitter { static readonly EVENT_CHANGE = "change"; static readonly EVENT_ERROR = "error"; static get currentlyPulling(): boolean; static readonly autorun: typeof autorun; static readonly reaction: typeof reaction; static readonly release: typeof release; static readonly afterRelease: typeof afterRelease; readonly context: Context; readonly meta: Meta; protected _writable: boolean; get writable(): boolean; protected _pull: TCellPull | null; protected _dependencyFilter: (dependency: Cell) => any; protected _validateValue: ((nextValue: Value, value: Value | undefined) => void) | null; protected _put: TCellPut | null; protected _compareValues: (nextValue: Value, value: Value | undefined) => boolean; protected _reap: (() => void) | null; protected _nextDependency: IDependencyList | null | undefined; protected _currentDependency: IDependencyList | null; protected _nextDependent: IDependentList | null; protected _lastDependent: IDependentList | null; getDependencies(): Cell[]; getDependents(): Cell[]; protected _value: Value | undefined; protected _error$: Cell | null; protected _error: Error | null; protected _bound: boolean; protected _initialized: boolean; get initialized(): boolean; protected _active: boolean; get active(): boolean; protected _state: CellState; get state(): CellState; protected _currentlyPulling: boolean; protected _updateId: number; constructor(options: ICellOptions); on(type: typeof Cell.EVENT_CHANGE, listener: TCellChangeEventListener>, context?: C): this; on(type: typeof Cell.EVENT_ERROR, listener: TCellErrorEventListener>, context?: C): this; on(listeners: ICellListeners>, context?: C): this; off(type: typeof Cell.EVENT_CHANGE, listener: TCellChangeEventListener>, context?: C): this; off(type: typeof Cell.EVENT_ERROR, listener: TCellErrorEventListener>, context?: C): this; off(listeners?: ICellListeners>, context?: C): this; onChange(listener: TCellChangeEventListener>, context?: C): this; offChange(listener: TCellChangeEventListener>, context?: C): this; onError(listener: TCellErrorEventListener>, context?: C): this; offError(listener: TCellErrorEventListener>, context?: C): this; subscribe(listener: (this: C extends undefined ? (typeof this)['context'] : C, err: Error | null, evt: TCellEvent) => any, context?: C): this; unsubscribe(listener: (this: C extends undefined ? (typeof this)['context'] : C, err: Error | null, evt: TCellEvent) => any, context?: C): this; protected _addDependent(dependent: Cell): void; protected _deleteDependent(dependent: Cell): void; protected _activate(): void; protected _deactivate(): void; protected _onValueChange(evt: IEvent): void; protected _addToRelease(): void; actualize(): this; _actualize(): this; get value(): Value; set value(value: Value); get error(): Error | null; get(): Value; pull(): boolean; set(value: Value): this; push(value: Value): boolean; _push(value: Value, fromPull?: boolean): boolean; fail(err: any): boolean; _fail(err: any, fromPull?: boolean): boolean; wait(): never; reap(): this; dispose(): this; }