Is there any programmatical advantage of one of these approaches over the other?
actions.js
export const USER_CLOSED_DIALOG = 'USER_CLOSED_DIALOG';
export function userClosedDialog() {
return (dispatch) => {
dispatch(closeDialog());
}
}
export USER_SAVED_DATA = 'USER_SAVED_DATA';
export function userSavedData() {
return (dispatch) => {
dispatch(closeDialog());
}
}
export const CLOSE_DIALOG = 'CLOSE_DIALOG';
export function closeDialog() {
return { type: CLOSE_DIALOG }
}
versus:
reducers.js
switch (action.type) {
case USER_CLOSED_DIALOG:
case USER_SAVED_DATA:
case CLOSE_DIALOG:
return { ...state, dialogOpen: false };
default:
return state;
}
Or are these pretty much equivalent and it's just a matter of preference? The only advantage I can see to using thunks is that one could perform additional processing if the user saved data vs just clicking the close button. It at least leaves that option open for later.