Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
helderberto committed Aug 11, 2020
1 parent 432da0f commit b58c534
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Expand Up @@ -618,6 +618,31 @@ fetch('someurl/data').catch(error => {
);
```
##### A sample using redux-thunk
```js
const fetchApi = (params) => {
function thunk(dispatch, getState) {
YourService.save(params)
.then(response => {
console.log('[success]:', response)
})
.catch(error => {
console.error('[error]:', error);
dispatch(offlineActionCreators.fetchOfflineMode(thunk));
});
}

thunk.interceptInOffline = true;

thunk.meta = {
retry: true,
name: 'fetchApi',
args: [params],
};
return thunk;
};
```
#### How to persist and rehydrate thunks in the offline queue with Redux Persist
Due to the way Redux Persist serializes the store, persisting and rehydrating thunks will return an invalid action. Fortunately, there is a workaround.
Expand Down

0 comments on commit b58c534

Please sign in to comment.