Skip to content

Instantly share code, notes, and snippets.

@peteruithoven
Last active February 11, 2016 18:33
Show Gist options
  • Save peteruithoven/b43a6d2cd6c3d2c1a923 to your computer and use it in GitHub Desktop.
Save peteruithoven/b43a6d2cd6c3d2c1a923 to your computer and use it in GitHub Desktop.
Example of storing data over hot reloads (using capaj/systemjs-hot-reloader)
/**
* Utility to store data over hot reloads.
*/
const globalStore = {};
export default function getHotReloadStore(key) {
if (globalStore[key] === undefined) {
globalStore[key] = {};
}
return globalStore[key];
}
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;
@peteruithoven
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment