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
This could help in reducing boilerplate using DUCKS while writing actions and reducers. Use would need to include respective creators utils for constants, actions and reducers. Hence it will help in writing much cleaner code and fast development.
The text was updated successfully, but these errors were encountered:
actionDispatcher=fetch=>asyncdispatch{const[init,loading,success,error]=actionCreate('user','get_profile');try{dispatch({type: init})// init is => INIT/USER/GET_PROFILEdispatch({type: loading});// loading is=> LOADING/USER/GET_PROFILEconstpayload=awaitfetch();dispatch({type: success, payload })// success=> SUCCESS/USER/GET_PROFILEreturnpayload;}catch(error){dispatch({type: error})// error is => ERROR/USER/GET_PROFILEthrowerror;}}
Then use it something like this;
constmyFooApiCall=async()=>{try{constresult=awaitfetch('http://some-api-call',{method: '',headers: {},});returnresult;}catch(error){throwerror;}}// use it like thisdispatch(actionDispatcher(myFooApiCall))
adeelibr
changed the title
[Feature] Proposal to add a new section redux utils
[Feature] Proposal Redux DUCKS action creaters & action dispatchers helpers
Feb 4, 2019
This could help in reducing boilerplate using DUCKS while writing actions and reducers. Use would need to include respective creators utils for constants, actions and reducers. Hence it will help in writing much cleaner code and fast development.
The text was updated successfully, but these errors were encountered: