@turbox3d/reactivity
Version:
Large-scale reactive state management library
58 lines (57 loc) • 1.77 kB
TypeScript
import { ActionType } from './store';
import { ECollectType } from '../const/enums';
import { HistoryOperationType } from '../interfaces';
import { Action } from './action';
export interface DiffInfo {
type: ECollectType;
beforeUpdate: any;
didUpdate: any;
}
export type KeyToDiffChangeMap = Map<any, DiffInfo>;
export type History = Map<object, KeyToDiffChangeMap>;
export interface HistoryNode {
actionChain: ActionType[];
history: History;
}
export interface HistoryCollectorPayload {
type: ECollectType;
beforeUpdate?: any;
didUpdate?: any;
}
/**
* collect prop diff history record
*/
export declare class TimeTravel {
static timeTravels: Record<string, TimeTravel>;
static currentTimeTravel?: TimeTravel;
static processing: boolean;
static switch: (name: string) => void;
static create: (name: string) => TimeTravel;
static get: (name: string) => TimeTravel | undefined;
static pause: () => void;
static resume: () => void;
static undo: () => void;
static redo: () => void;
static clear: () => void;
static get undoable(): boolean | undefined;
static get redoable(): boolean | undefined;
static undoHandler(history: History): void;
static redoHandler(history: History): void;
get undoable(): boolean;
get redoable(): boolean;
currentHistory: History;
transactionHistories: HistoryNode[];
cursor: number;
onChange(undoable: boolean, redoable: boolean, type: HistoryOperationType, action?: Action): void;
/**
* @todo support multiple steps
* revert to the previous history status
*/
undo(): void;
/**
* @todo support multiple steps
* apply the next history status
*/
redo(): void;
clear(): void;
}