Guest User

Untitled

a guest
Feb 25th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. const cache = store => next => action => {
  2. // handle FETCH action only
  3. if (action.type !== 'FETCH') {
  4. return next(action);
  5. }
  6.  
  7. // check if cache is available
  8. const data = window['__data'];
  9. if (!data) {
  10. // forward the call to live middleware
  11. return next(action);
  12. }
  13. return store.dispatch({ type: 'RECEIVE', payload: { data: `${data} (from cache)` } });
  14. }
  15.  
  16. export default cache;
Add Comment
Please, Sign In to add comment