-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.d.ts
93 lines (76 loc) · 2.67 KB
/
index.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
90
91
92
93
import {
Action,
Dispatch,
Middleware,
MiddlewareAPI,
StoreEnhancer,
} from 'redux'
import { Stream } from 'most'
/*****************************************
Type abbreviations:
A = Action
T = ActionType (a string or symbol)
S = State
*****************************************/
// default to the most common use case, but allow overriding
export type ActionType = string
export interface DefaultAction extends Action<ActionType> {
[key: string]: any
}
// for the original, redux-observable style API
export type OriginalApiEpic<S, A extends Action = DefaultAction> = (
actionStream: Stream<A>,
middlewareApi: MiddlewareAPI<Dispatch<A>, S>,
) => Stream<A>
// for the newer, declarative only API, which takes in a state stream
// to sample via the withState utility instead of exposing dispatch/getState
export type DeclarativeApiEpic<S, A extends Action = DefaultAction> = (
actionStream: Stream<A>,
stateStream: Stream<S>,
) => Stream<A>
export type Epic<S, A extends Action = DefaultAction> =
| OriginalApiEpic<S, A>
| DeclarativeApiEpic<S, A>
export interface EpicMiddleware<S, A extends Action = DefaultAction>
extends Middleware {
replaceEpic(nextEpic: Epic<S, A>): void
}
export declare function createEpicMiddleware<
S,
A extends Action = DefaultAction
>(rootEpic: Epic<S, A>): EpicMiddleware<S, A>
export declare function createStateStreamEnhancer<
S,
A extends Action = DefaultAction
>(epicMiddleware: EpicMiddleware<S, A>): StoreEnhancer<S>
export declare function combineEpics<S, A extends Action = DefaultAction>(
epicsArray: Epic<S, A>[],
): Epic<S, A>
// overloads exist due to select being a curried function
export declare function select<
A extends Action = DefaultAction,
T = ActionType
>(actionType: T, stream: Stream<A>): Stream<A>
export declare function select<
A extends Action = DefaultAction,
T = ActionType
>(actionType: T): (stream: Stream<A>) => Stream<A>
// overloads exist due to selectArray being a curried function
export declare function selectArray<
A extends Action = DefaultAction,
T = ActionType
>(actionTypes: T[], stream: Stream<A>): Stream<A>
export declare function selectArray<
A extends Action = DefaultAction,
T = ActionType
>(actionTypes: T[]): (stream: Stream<A>) => Stream<A>
// overloads exist due to withState being a curried function
export declare function withState<S, A extends Action = DefaultAction>(
stateStream: Stream<S>,
actionStream: Stream<A>,
): Stream<[S, A]>
export declare function withState<S, A extends Action = DefaultAction>(
stateStream: Stream<S>,
): (actionStream: Stream<A>) => Stream<[S, A]>
export const EPIC_END = '@@redux-most/EPIC_END'
export type EPIC_END = typeof EPIC_END