@turbox3d/reactivity
Version:
Large-scale reactive state management library
40 lines (39 loc) • 1.41 kB
TypeScript
import { Reaction } from './reactive';
import { HistoryCollectorPayload } from './time-travel';
import { EDepState } from '../const/enums';
import { Action } from './action';
import { KeyPathType } from './domain';
export type ReactionId = any | Reaction;
export type DepNodeAssembly = Map<any, Set<ReactionId>>;
export type DepNodeStatus = Map<any, EDepState>;
/**
* collect relation map of the dep key and the reaction ids
*/
declare class DepCollector {
dependencyGraph: Map<object, DepNodeAssembly>;
reactionIdDeps: Map<any, Map<object, DepNodeStatus>>;
private reactionIdStack;
start(id: ReactionId): void;
collect(target: object, propertyKey: any): void;
end(): void;
clear(id: ReactionId): void;
isObserved(targetKey: object, propKey: string): boolean;
}
export declare const depCollector: DepCollector;
declare class TriggerCollector {
waitTriggerIds: Set<ReactionId>;
trigger(target: object, key: any, payload: HistoryCollectorPayload, isNeedRecord?: boolean, devToolInfo?: {
keyPath: Array<{
type: KeyPathType;
value: string;
}>;
domain: string;
}): void;
endBatch(isClearHistory?: boolean, action?: Action): void;
save(action?: Action): void;
private collectComponentId;
private recordDiff;
private saveHistory;
}
export declare const triggerCollector: TriggerCollector;
export {};