Skip to content

Instantly share code, notes, and snippets.

@daverivera
Last active May 29, 2019 11:47
Show Gist options
  • Save daverivera/f6ed0b1cba6bb268ada06c18b97fe4f9 to your computer and use it in GitHub Desktop.
Save daverivera/f6ed0b1cba6bb268ada06c18b97fe4f9 to your computer and use it in GitHub Desktop.
redux-crosstab_localstorage_middleware
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