index.js 885 B

12345678910111213141516171819202122
  1. import { put, takeEvery, all } from 'redux-saga/effects'
  2. import { actionClearDataUserType } from '../../../actions/types/userTypes'
  3. import { actionClearFeedPostsType } from '../../../actions/types/feedTypes'
  4. import { actionAllClearPromiseType } from '../../../actions/types/promiseTypes'
  5. import { actionClearAboutMeType } from '../../../actions/types/myDataTypes'
  6. import { actionAuthLogout } from '../../../actions/types/loginTypes'
  7. import history from '../../../helpers/history'
  8. function* clearAllDataWorker() {
  9. const logOut = yield put(actionAuthLogout())
  10. if (logOut) {
  11. history.push('/input')
  12. yield all([
  13. put(actionClearDataUserType()),
  14. put(actionClearFeedPostsType()),
  15. put(actionClearAboutMeType()),
  16. put(actionAllClearPromiseType()),
  17. ])
  18. }
  19. }
  20. export function* clearAllDataWatcher() {
  21. yield takeEvery('CLEAR_ALL_DATA', clearAllDataWorker)
  22. }