2020-02-03 18:42:31 +05:00
|
|
|
import { all, call, cancel, fork, take } from 'redux-saga/effects';
|
2019-08-31 04:07:25 +05:00
|
|
|
|
|
|
|
|
import watchers from './watchers';
|
|
|
|
|
import { goToRootService } from './services';
|
|
|
|
|
import { setAccessToken } from '../../utils/access-token-storage';
|
|
|
|
|
import ActionTypes from '../../constants/ActionTypes';
|
|
|
|
|
|
2020-02-03 18:42:31 +05:00
|
|
|
export default function*() {
|
|
|
|
|
const watcherTasks = yield all(watchers.map(watcher => fork(watcher)));
|
2019-08-31 04:07:25 +05:00
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
payload: { accessToken },
|
|
|
|
|
} = yield take(ActionTypes.AUTHENTICATE_SUCCEEDED);
|
|
|
|
|
|
|
|
|
|
yield cancel(watcherTasks);
|
|
|
|
|
|
|
|
|
|
yield call(setAccessToken, accessToken);
|
|
|
|
|
yield call(goToRootService);
|
|
|
|
|
}
|