You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Required:
somehow inside of controller without a lot of boilerplate code to get next: at begin of method dispatch action with promise for promise-middleware, that will be resolved/rejected at the end of method.
Recap:
at begin of method set some redux state to true
at end of method set same redux state to false
at error do same as at (2)
In most cases it's common loading flag (e.g. API requests) to make UI to response changes of state (e.g. block/unblock controls).
Right now I'm doing it like this, but not sure that it's good way, maybe I miss something:
constgenerators={*initialize(){const{ dispatch }=yieldgetProps;this.onLogin=blocking(types.APP_PREFIX,this.onLogin,dispatch);yieldthis.userInfo(true,'/');},*onSiderCollapse(){const{ dispatch }=yieldgetProps;dispatch(actions.siderCollapse());},*onLogin(params){const{ dispatch }=yieldgetProps;try{yieldapi.login(params);yieldthis.userInfo(false,'/');}catch(e){dispatch(error(e)),dispatch(auth.reset());}},*onLogout(){const{ dispatch }=yieldgetProps;try{yieldapi.logout();}catch(e){}dispatch(auth.reset());dispatch(navigate('/'));},*userInfo(silent=false,returnUrl){const{ dispatch, route }=yieldgetProps;try{dispatch(auth.request());constidentity=yieldapi.fetchCurrrentUser();dispatch(auth.receive(identity));//if route has url to return, then use itletredirect=route&&route.query&&route.query.return;if(!redirect){redirect=returnUrl;}if(redirect){dispatch(navigate(redirect));}}catch(e){console.log(e);if(!silent){dispatch(error(e));}dispatch(auth.reset());dispatch(navigate('/'));}}};
I'm not 100% sure what you're going for, but the idea of RRC was to prevent the need for async middleware.
Is the issue that you're trying to essentially apply a decorator (blocking) to a controller method, but that decorator needs a reference to dispatch, but you can only get a handle to it in initialize? Would it also be possible to make blocking a controller generator method?
Required:
somehow inside of controller without a lot of boilerplate code to get next: at begin of method dispatch action with promise for promise-middleware, that will be resolved/rejected at the end of method.
Recap:
In most cases it's common loading flag (e.g. API requests) to make UI to response changes of state (e.g. block/unblock controls).
Right now I'm doing it like this, but not sure that it's good way, maybe I miss something:
helper:
generators with marked onLogin as blocking:
I need it for my reducer, e.g.:
utils is like this:
The text was updated successfully, but these errors were encountered: