-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathTokenActions.js
More file actions
43 lines (37 loc) · 833 Bytes
/
TokenActions.js
File metadata and controls
43 lines (37 loc) · 833 Bytes
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
import context from './../context';
import TokenConstants from './../constants/TokenConstants';
/* istanbul ignore next */
function dispatch(event) {
setTimeout(() => {
context.getDispatcher().dispatch(event);
}, 0);
}
class TokenActions {
constructor(dispatch) {
this.dispatch = dispatch;
}
// Allows for setting mock dispatch in tests
setDispatch(dispatch) {
this.dispatch = dispatch;
}
set(type, token, callback) {
this.dispatch({
type: TokenConstants.TOKEN_SET,
options: {
type: type,
token: token
},
callback: callback
});
}
refresh(token, callback) {
this.dispatch({
type: TokenConstants.TOKEN_REFRESH,
options: {
token: token
},
callback: callback
});
}
}
export default new TokenActions(dispatch)