Utilizing ducks alongside Redux, I have multiple action creators within the same file. I am seeking a way to call one action creator from another without the need for double dispatching in every case within the switch statement below:
...
export function closeAuthDialogs() {
return {type: CLOSE_AUTH_DIALOGS}
}
export function openDialog(dialog) {
// Close any open dialogs
dispatch => {dispatch(closeAuthDialogs())} // <--THIS DOES NOT GET CALLED!!!
// Open the required dialog
switch (dialog) {
case 'login':
return {type: OPEN_LOGIN}
case 'register':
return {type: OPEN_REGISTER}
case 'forgot':
return {type: OPEN_FORGOT}
case 'change':
return {type: OPEN_CHANGE}
case 'profile':
return {type: OPEN_PROFILE}
default:
return;
}
}
...
The opening of dialogs works smoothly, but unfortunately, the close function does not trigger. Is there a method to invoke the close function from within the open function without double dispatching for each case in the switch statement?
By mentioning double dispatching, I am referring to...
return dispatch => {
dispatch({type: CLOSE_AUTH_DIALOGS})
dispatch({type: OPEN_SOME_DIALOG)}
}
If feasible, I would prefer to execute the close function once and then proceed with the specified open operation.
Thanks in advance!