My function add
does not return any promises to the caller.
Here's an example:
let add = (foo) => {this.props.save(foo)};
In another part of my application, I want to wait for add()
to finish before moving on to something else. However, I know that the async save
function does not return a promise, as it is a simple Redux action.
...
return add()
.then( ... do something else here ... );
export const save = (something) => (dispatch) => {
ApiUtil.patch(`google.com`, { data: {
something } }).
then(() => {
dispatch({ type: Constants.SET_FALSE });
},
() => {
dispatch({ type: Constants.SET_SAVE_FAILED,
payload: { saveFailed: true } });
});
};
I have included this code snippet to demonstrate the action being taken.