Skip to content

Commit 4140ae4

Browse files
committed
Add hot reloading readme
1 parent 04f676b commit 4140ae4

File tree

3 files changed

+39
-26
lines changed

3 files changed

+39
-26
lines changed

examples/hot-reloading/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
NuclearJS Hot Reloading
2+
===
3+
4+
NuclearJS supports hot reloading of stores. Using the webpack Hot Module Replacement simply code like this to wherever your stores are registered.
5+
6+
7+
```js
8+
import { Reactor } from 'nuclear-js'
9+
import * as stores from './stores'
10+
11+
const reactor = new Reactor({
12+
debug: true,
13+
})
14+
reactor.registerStores(stores)
15+
16+
if (module.hot) {
17+
// Enable webpack hot module replacement for stores
18+
module.hot.accept('./stores', () => {
19+
reactor.replaceStores(require('./stores'))
20+
})
21+
}
22+
23+
export default reactor
24+
```
25+
26+
## Running Example
27+
28+
```
29+
npm install
30+
npm start
31+
```
32+
33+
Go to [http://localhost:3000](http://localhost:3000)
34+
35+
## Inpsiration & Thanks
36+
37+
Big thanks to [redux](https://github.com/rackt/redux) and [react-redux](https://github.com/rackt/react-redux) for proving out this architecture
38+
and creating simple APIs to accomplish hot reloading.

examples/hot-reloading/npm-debug.log

Lines changed: 0 additions & 25 deletions
This file was deleted.

examples/hot-reloading/src/reactor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const reactor = new Reactor({
77
reactor.registerStores(stores)
88

99
if (module.hot) {
10-
// Enable Webpack hot module replacement for reducers
10+
// Enable Webpack hot module replacement for stores
1111
module.hot.accept('./stores', () => {
1212
reactor.replaceStores(require('./stores'))
1313
})

0 commit comments

Comments
 (0)