-
Notifications
You must be signed in to change notification settings - Fork 1
/
authSession.ts
69 lines (60 loc) · 2.01 KB
/
authSession.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
import { createAction } from '@reduxjs/toolkit';
import { actionType } from 'services/utils';
const types = {
AUTH_SESSION_START: actionType('AUTH_SESSION_START'),
AUTH_SESSION_END: actionType('AUTH_SESSION_END'),
AUTH_SESSION_PAUSE: actionType('AUTH_SESSION_PAUSE'),
AUTH_SESSION_RESUME: actionType('AUTH_SESSION_RESUME'),
} as const;
/**
* @ignore
*/
export const authSessionStart = createAction<void, typeof types['AUTH_SESSION_START']>(types.AUTH_SESSION_START);
/**
* @ignore
*/
export const authSessionEnd = createAction<void, typeof types['AUTH_SESSION_END']>(types.AUTH_SESSION_END);
/**
* @ignore
*/
export const authSessionPause = createAction<void, typeof types['AUTH_SESSION_PAUSE']>(types.AUTH_SESSION_PAUSE);
/**
* @ignore
*/
export const authSessionResume = createAction<void, typeof types['AUTH_SESSION_RESUME']>(types.AUTH_SESSION_RESUME);
/**
* Once a user has been successfully logged in, this action is dispatched. It's guaranteed that `AUTH_SESSION_END` must be triggered first before another `AUTH_SESSION_START` trigger.
*
* @category Redux Action Type
*
* @example
* ```ts
* import { put } from 'redux-saga/effects';
* import { AUTH_SESSION_START } from '@ackee/petrus';
*
* function* watchAuthSession() {
* yield takeEvery(AUTH_SESSION_START, function* (action) {
* // ...
* });
* }
* ```
*/
export const AUTH_SESSION_START = authSessionStart.type;
/**
* This action is triggered on the access token refreshment start.
*
* @category Redux Action Type
*/
export const AUTH_SESSION_PAUSE = authSessionPause.type;
/**
* If access token refreshment was successful, `AUTH_SESSION_RESUME` is triggered. It's guaranteed it will be dispatched only after `AUTH_SESSION_PAUSE` action.
*
* @category Redux Action Type
*/
export const AUTH_SESSION_RESUME = authSessionResume.type;
/**
* The `AUTH_SESSION_END` action is triggered on `AUTH_LOGOUT_SUCCESS` or `REFRESH_TOKENS_FAILURE`.
*
* @category Redux Action Type
*/
export const AUTH_SESSION_END = authSessionEnd.type;