redux-wait-for-action icon indicating copy to clipboard operation
redux-wait-for-action copied to clipboard

the middleware can't catch the redux-saga put invoked action

Open kidyfirst opened this issue 7 years ago • 1 comments

//componet.js this.props.dispatch({ ...AuthAction.getToken({ username: this.state.username, password: this.state.password }) , [WAIT_FOR_ACTION]: AuthAction.TOKEN, [ERROR_ACTION]: ToastAction.REMOVE_TOAST }).then(() => { this.props.history.push('/list'); }) .catch(() => { this.setState({ loading:false }) });

//saga.js public static* getToken(params: IAction<IGetToken>){ try{ const response: any = yield call(AuthService.getAuthToken, params.payload); const auth: IAuth = get(response, 'data');

  if (auth) {
    yield put(AuthAction.getTokenData(auth))
  }else{
    yield put(showToast({
      type:AuthAction.GET_TOKEN,
      msg: response
    }))
  }
}catch (e) {
  yield put(showToast({
    type: AuthAction.GET_TOKEN,
    msg: "生成用户token异常"
  }));
}

}

when i debug the middleware, i fond it can't get the AuthAction.getTokenData(auth) action, and it also can't catch all pulled action by saga. debugger in line: return function (action) {

   ->    for (var i = pendingActionList.length - 1; i >= 0; i--) {

kidyfirst avatar Oct 01 '18 14:10 kidyfirst

I find the reason, because i use the devtool. before: const enhancer = compose( applyMiddleware(sagaMiddleware), composeWithDevTools(applyMiddleware(sagaMiddleware)) ); after: const enhancer = compose( applyMiddleware(sagaMiddleware), applyMiddleware(createReduxWaitForMiddleware()), // composeWithDevTools(applyMiddleware(sagaMiddleware)) );

kidyfirst avatar Oct 01 '18 15:10 kidyfirst