undox
Version:
Redux implementation of Undo/Redo based on storing actions instead of states.
38 lines (37 loc) • 1.25 kB
TypeScript
import { Action } from './interfaces/public';
export declare enum UndoxTypes {
UNDO = "undox/UNDO",
REDO = "undox/REDO",
GROUP = "undox/GROUP"
}
/**
* Undo a number of actions
* @interface
* @member {number} payload - The number of steps to undo (must be positive and less than the length of the past)
*/
export interface UndoAction extends Action {
readonly type: UndoxTypes.UNDO;
payload?: number;
}
/**
* Redo a number of actions
* @interface
* @member {number} payload - The number of steps to redo (must be positive and less than the length of the future)
*/
export interface RedoAction extends Action {
readonly type: UndoxTypes.REDO;
payload?: number;
}
/**
* Group actions
* @interface
* @member {Action[]} payload - An array of actions which will be grouped into one
*/
export interface GroupAction<A extends Action> extends Action {
readonly type: UndoxTypes.GROUP;
payload: A[];
}
export declare const redo: (nStates?: number) => RedoAction;
export declare const undo: (nStates?: number) => UndoAction;
export declare const group: <A extends Action<any>>(actions: A[]) => GroupAction<A>;
export declare type UndoxAction<A extends Action> = UndoAction | RedoAction | GroupAction<A> | A;