From 4140ae447627a84bd2208aa638941eb91239db4c Mon Sep 17 00:00:00 2001 From: jordangarcia Date: Wed, 23 Dec 2015 17:14:02 -0500 Subject: [PATCH] Add hot reloading readme --- examples/hot-reloading/README.md | 38 +++++++++++++++++++++++++++ examples/hot-reloading/npm-debug.log | 25 ------------------ examples/hot-reloading/src/reactor.js | 2 +- 3 files changed, 39 insertions(+), 26 deletions(-) create mode 100644 examples/hot-reloading/README.md delete mode 100644 examples/hot-reloading/npm-debug.log diff --git a/examples/hot-reloading/README.md b/examples/hot-reloading/README.md new file mode 100644 index 0000000..c4db313 --- /dev/null +++ b/examples/hot-reloading/README.md @@ -0,0 +1,38 @@ +NuclearJS Hot Reloading +=== + +NuclearJS supports hot reloading of stores. Using the webpack Hot Module Replacement simply code like this to wherever your stores are registered. + + +```js +import { Reactor } from 'nuclear-js' +import * as stores from './stores' + +const reactor = new Reactor({ + debug: true, +}) +reactor.registerStores(stores) + +if (module.hot) { + // Enable webpack hot module replacement for stores + module.hot.accept('./stores', () => { + reactor.replaceStores(require('./stores')) + }) +} + +export default reactor +``` + +## Running Example + +``` +npm install +npm start +``` + +Go to [http://localhost:3000](http://localhost:3000) + +## Inpsiration & Thanks + +Big thanks to [redux](https://github.com/rackt/redux) and [react-redux](https://github.com/rackt/react-redux) for proving out this architecture +and creating simple APIs to accomplish hot reloading. diff --git a/examples/hot-reloading/npm-debug.log b/examples/hot-reloading/npm-debug.log deleted file mode 100644 index 20288c0..0000000 --- a/examples/hot-reloading/npm-debug.log +++ /dev/null @@ -1,25 +0,0 @@ -0 info it worked if it ends with ok -1 verbose cli [ '/Users/jordan/.nvm/versions/node/v5.0.0/bin/node', -1 verbose cli '/Users/jordan/.nvm/versions/node/v5.0.0/bin/npm', -1 verbose cli 'start' ] -2 info using npm@3.3.6 -3 info using node@v5.0.0 -4 verbose stack Error: missing script: start -4 verbose stack at run (/Users/jordan/.nvm/versions/node/v5.0.0/lib/node_modules/npm/lib/run-script.js:148:19) -4 verbose stack at /Users/jordan/.nvm/versions/node/v5.0.0/lib/node_modules/npm/lib/run-script.js:58:5 -4 verbose stack at /Users/jordan/.nvm/versions/node/v5.0.0/lib/node_modules/npm/node_modules/read-package-json/read-json.js:345:5 -4 verbose stack at checkBinReferences_ (/Users/jordan/.nvm/versions/node/v5.0.0/lib/node_modules/npm/node_modules/read-package-json/read-json.js:309:45) -4 verbose stack at final (/Users/jordan/.nvm/versions/node/v5.0.0/lib/node_modules/npm/node_modules/read-package-json/read-json.js:343:3) -4 verbose stack at then (/Users/jordan/.nvm/versions/node/v5.0.0/lib/node_modules/npm/node_modules/read-package-json/read-json.js:113:5) -4 verbose stack at ReadFileContext. (/Users/jordan/.nvm/versions/node/v5.0.0/lib/node_modules/npm/node_modules/read-package-json/read-json.js:284:20) -4 verbose stack at ReadFileContext.callback (/Users/jordan/.nvm/versions/node/v5.0.0/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:76:16) -4 verbose stack at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:324:13) -5 verbose cwd /Users/jordan/code/nuclear/examples/hot-reloading -6 error Darwin 14.4.0 -7 error argv "/Users/jordan/.nvm/versions/node/v5.0.0/bin/node" "/Users/jordan/.nvm/versions/node/v5.0.0/bin/npm" "start" -8 error node v5.0.0 -9 error npm v3.3.6 -10 error missing script: start -11 error If you need help, you may report this error at: -11 error -12 verbose exit [ 1, true ] diff --git a/examples/hot-reloading/src/reactor.js b/examples/hot-reloading/src/reactor.js index 6a855c3..aa92c41 100644 --- a/examples/hot-reloading/src/reactor.js +++ b/examples/hot-reloading/src/reactor.js @@ -7,7 +7,7 @@ const reactor = new Reactor({ reactor.registerStores(stores) if (module.hot) { - // Enable Webpack hot module replacement for reducers + // Enable Webpack hot module replacement for stores module.hot.accept('./stores', () => { reactor.replaceStores(require('./stores')) })