Last active
February 11, 2016 18:33
-
-
Save peteruithoven/b43a6d2cd6c3d2c1a923 to your computer and use it in GitHub Desktop.
Example of storing data over hot reloads (using capaj/systemjs-hot-reloader)
This file contains 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
/** | |
* Utility to store data over hot reloads. | |
*/ | |
const globalStore = {}; | |
export default function getHotReloadStore(key) { | |
if (globalStore[key] === undefined) { | |
globalStore[key] = {}; | |
} | |
return globalStore[key]; | |
} |
This file contains 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
import getHotReloadStore from './utils/getHotReloadStore.js'; | |
const hotStore = getHotReloadStore('d3d:store'); | |
const state = hotStore.state || { | |
counter: 0 | |
}; | |
console.log('state: ', state); | |
state.counter += 1; | |
hotStore.state = state; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Full example: https://github.com/peteruithoven/hot-reload-store-example