0.0.0 • Published 9 years ago
redux-optimistic v0.0.0
Redux Optimistic
Simple, user controlled optimistic updates for redux.
how?
When you a remote call that can succeed or fail, simply add a key to your dispatched action describing the remote call(this should be a promise) and what to do if it succeeds or fails
dispatch({
type: MY_CONST
payload: optimisticData,
remote: {
action: promiseThatCanSucceedOrFail,
onSuccess: /* FUNCTION TO CALL ON SUCCESS, will receive state before action is committed to state, current state and the response */,
onFail: /* FUNCTION TO CALL ON FAILURE, will receive state before action is committed to state, current state and the error */
}
});
0.0.0
9 years ago