Created
May 3, 2018 15:03
-
-
Save kulor/b1b424f6bf578cd2814a67d04c4c1d9d to your computer and use it in GitHub Desktop.
Example Redux Offline action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const followUser = userId => ({ | |
type: 'FOLLOW_USER_REQUEST', | |
payload: { userId }, | |
meta: { | |
offline: { | |
// the network action to execute: | |
effect: { url: '/api/follow', method: 'POST', body: JSON.stringify({ userId }) }, | |
// action to dispatch when effect succeeds: | |
commit: { type: 'FOLLOW_USER_COMMIT', meta: { userId } }, | |
// action to dispatch if network action fails permanently: | |
rollback: { type: 'FOLLOW_USER_ROLLBACK', meta: { userId } } | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment