kirill-konshin / next-redux-wrapper

Redux wrapper for Next.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Waiting for an action with takeMaybe / take after END is dispatched for SSR

sandeepahuja-stack opened this issue · comments

Waiting for an action with takeMaybe / take after END is dispatched for SSR

function actionStateUpdate(data){
  return {
   type : 'STATE_UPDATE',
   payload: data
  }
}
function *abc(action){
  const response = yield call(api);
  yield put(actionStateUpdate, response);
  // state is getting updated 
  const state = yield select();
}

function *xyz(action){
  // used both take/takeMaybe
  const wantsToUseActionPayload = yield takeMaybe('STATE_UPDATE');
  console.log("here", wantsToUseActionPayload)
  //in case of take, console is not getting printed
  // in case of takeMayBe  getting => { type: '@@redux-saga/CHANNEL_END' }

  const state = yield select();
  // unable to found updated state 
}

Using Next Js and next redux wrapper
in Get server side props,

store.dispatch(END as any) 
await store.sagaTask.toPromise()