Currently, if you have an asynchronous action, you are in charge of calling store.setState manually, while synchronous actions can just return the state update, and setState is called after the return. What if actions could return Promises and setState was called after the Promise resolves? Something like this:
// Action
async incrementAsync(state) {
const response = await fetch("data.json");
const data = await response.json();
return { data };
}
// Mapped action
// https://github.com/developit/unistore/blob/master/unistore.js#L78
Promise.resolve(actions[i](store.getState(), ...args)).then(store.setState);
Currently, if you have an asynchronous action, you are in charge of calling
store.setStatemanually, while synchronous actions can just return the state update, and setState is called after the return. What if actions could return Promises and setState was called after the Promise resolves? Something like this: