Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const cache = store => next => action => {
- // handle FETCH action only
- if (action.type !== 'FETCH') {
- return next(action);
- }
- // check if cache is available
- const data = window['__data'];
- if (!data) {
- // forward the call to live middleware
- return next(action);
- }
- return store.dispatch({ type: 'RECEIVE', payload: { data: `${data} (from cache)` } });
- }
- export default cache;
Add Comment
Please, Sign In to add comment