Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. import { takeEvery, put, select } from 'redux-saga/effects'
  2.  
  3. function* initApp(action) {
  4. const location = yield select(state => state.router.location);
  5. const params = new URLSearchParams(location.search.split("?")[1]);
  6. const items = Array.from(params.entries()).filter(item => item[0] === 'item').map(item => item[1]);
  7. yield put({type: "ADD_ITEMS", data: items})
  8. return;
  9. }
  10.  
  11.  
  12. function* mySaga() {
  13. yield takeEvery("INIT_APP", initApp);
  14. }
  15.  
  16. export default mySaga;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement