forked from omnidan/redux-undo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
typings.d.ts
89 lines (68 loc) · 2.7 KB
/
typings.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
declare module 'redux-undo' {
import { Reducer, Action } from 'redux';
export interface StateWithHistory<State> {
past: State[];
present: State;
future: State[];
}
export type FilterFunction = (action: Action) => boolean;
export type CombineFilters = (...filters: FilterFunction[]) => FilterFunction;
export class ActionCreators {
static undo: () => Action;
static redo: () => Action;
static jump: (point: number) => Action;
static jumpToPast: (index: number) => Action;
static jumpToFuture: (index: number) => Action;
static clearHistory: () => Action;
}
export class ActionTypes {
static UNDO: string;
static REDO: string;
static JUMP: string;
static JUMP_TO_PAST: string;
static JUMP_TO_FUTURE: string;
static CLEAR_HISTORY: string;
}
interface Options {
/* Set a limit for the history */
limit?: number;
/** If you don't want to include every action in the undo/redo history, you can add a filter function to undoable */
filter?: FilterFunction;
/** Define a custom action type for this undo action */
undoType?: string;
/** Define a custom action type for this redo action */
redoType?: string;
/** Define custom action type for this jump action */
jumpType?: string;
/** Define custom action type for this jumpToPast action */
jumpToPastType?: string;
/** Define custom action type for this jumpToFuture action */
jumpToFutureType?: string;
/** [beta only] Define custom action type for this clearHistory action */
clearHistoryType?: string;
/** History will be (re)set upon init action type */
initTypes?: string[];
/** Set to `true` to turn on debugging */
debug?: boolean;
/** Set to `true` to prevent undoable from skipping the reducer on undo/redo **/
neverSkipReducer?: boolean;
}
interface Undoable {
<State>(reducer: Reducer<State>, options?: Options): Reducer<StateWithHistory<State>>;
}
type IncludeAction = (actions: string | string[]) => FilterFunction;
type ExcludeAction = IncludeAction;
const undoable: Undoable;
export default undoable;
/**
* If you don't want to include every action in the undo/redo history, you can add a filter function to undoable.
* redux-undo provides you with the includeAction and excludeAction helpers for basic filtering.
*/
export const includeAction: IncludeAction;
/**
* If you don't want to include every action in the undo/redo history, you can add a filter function to undoable.
* redux-undo provides you with the includeAction and excludeAction helpers for basic filtering.
*/
export const excludeAction: ExcludeAction;
export const combineFilters: CombineFilters;
}