Last active
May 29, 2019 11:47
-
-
Save daverivera/f6ed0b1cba6bb268ada06c18b97fe4f9 to your computer and use it in GitHub Desktop.
redux-crosstab_localstorage_middleware
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 storageKey = 'redux-local-tab-sync' | |
export function storageMiddleware() { | |
return () => next => action => { | |
if (!action.source) { | |
const wrappedAction = Object.assign({ source: 'another tab' }, action) | |
localStorage.setItem(storageKey, JSON.stringify(wrappedAction)) | |
} | |
next(action) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment