-
Notifications
You must be signed in to change notification settings - Fork 1
/
accessTokenAvailability.ts
35 lines (30 loc) · 1.14 KB
/
accessTokenAvailability.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
import { createAction } from '@reduxjs/toolkit';
import { actionType } from 'services/utils';
import type { PetrusTokens } from 'types';
const types = {
ACCESS_TOKEN_AVAILABLE: actionType('ACCESS_TOKEN_AVAILABLE'),
ACCESS_TOKEN_UNAVAILABLE: actionType('ACCESS_TOKEN_UNAVAILABLE'),
} as const;
/**
* @ignore
*/
export const accessTokenAvailable = createAction<PetrusTokens['accessToken'], typeof types['ACCESS_TOKEN_AVAILABLE']>(
types.ACCESS_TOKEN_AVAILABLE,
);
/**
* @ignore
*/
export const accessTokenUnavailable = createAction<void, typeof types['ACCESS_TOKEN_UNAVAILABLE']>(
types.ACCESS_TOKEN_UNAVAILABLE,
);
/**
* When the access token becomes available, this action is dispatched (on LOGIN_SUCCESS and REFRESH_TOKENS_SUCCESS).
* @category Redux Action Type
*/
export const ACCESS_TOKEN_AVAILABLE = accessTokenAvailable.type;
/**
* Access token becomes unavailable on logout or when tokens refreshment start.
* It's guaranteed that the `ACCESS_TOKEN_UNAVAILABLE` action will be dispatched only once after `ACCESS_TOKEN_AVAILABLE`.
* @category Redux Action Type
*/
export const ACCESS_TOKEN_UNAVAILABLE = accessTokenUnavailable.type;