Skip to content

Commit 52bb017

Browse files
feat(overmind): ability to turn off hot reloading
1 parent 0111ad9 commit 52bb017

File tree

8 files changed

+41
-34
lines changed

8 files changed

+41
-34
lines changed

packages/node_modules/overmind/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ export class Overmind<ThisConfig extends IConfiguration>
208208
if (
209209
IS_DEVELOPMENT &&
210210
mode.mode === MODE_DEFAULT &&
211-
!(process && process.title === 'node')
211+
options.hotReloading !== false &&
212+
!(process && process.title && process.title.includes('node'))
212213
) {
213214
if (hotReloadingCache[name]) {
214215
return hotReloadingCache[name].reconfigure(configuration)

packages/node_modules/overmind/src/internalTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export type Options = {
1414
name?: string
1515
devtools?: string | boolean
1616
logProxies?: boolean
17+
hotReloading?: boolean
1718
}
1819

1920
export type DefaultMode = {

packages/overmind-website/api/overmind.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,10 @@ If you have multiple instances of Overmind on the same page you can name your ap
4444
```marksy
4545
h(Example, { name: "api/app_options_name" })
4646
```
47+
48+
## options.hotReloading
49+
By default Overmind will do the necessary hot reloading mechanism to keep your state, actions and effects updated. You might not want to use this feature or Overmind does not correctly detect that hot reloading should be turned off. You can turn it off with an option.
50+
51+
```marksy
52+
h(Example, { name: "api/app_options_hotreloading" })
53+
```

packages/overmind-website/examples/api/app_initialize.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,15 @@ export const config = {
2525
{
2626
fileName: 'overmind/index.js',
2727
code: `
28-
import { createOvermind } from 'overmind'
29-
import { createConnect } from 'overmind-${view}'
30-
import state from './state'
28+
import { state } from './state'
3129
import * as effects from './effects'
3230
import * as actions from './actions'
3331
34-
export const overmind = createOvermind({
32+
export const config = {
3533
state,
3634
effects,
3735
actions
38-
})
39-
40-
export const connect = createConnect(overmind)
36+
}
4137
`,
4238
},
4339
]

packages/overmind-website/examples/api/app_options_devtools.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,17 @@ export default (ts) =>
22
ts
33
? [
44
{
5-
fileName: 'overmind/index.ts',
65
code: `
7-
...
8-
9-
export const overmind = createOvermind(config, {
6+
const overmind = createOvermind(config, {
107
devtools: true // 'localhost:3031'
118
})
129
`,
1310
},
1411
]
1512
: [
1613
{
17-
fileName: 'overmind/index.js',
1814
code: `
19-
...
20-
21-
export const overmind = createOvermind(config, {
15+
const overmind = createOvermind(config, {
2216
devtools: true // 'localhost:3031'
2317
})
2418
`,
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export default (ts) =>
2+
ts
3+
? [
4+
{
5+
code: `
6+
const overmind = createOvermind(config, {
7+
hotReloading: false
8+
})
9+
`,
10+
},
11+
]
12+
: [
13+
{
14+
code: `
15+
const overmind = createOvermind(config, {
16+
hotReloading: false
17+
})
18+
`,
19+
},
20+
]

packages/overmind-website/examples/api/app_options_logproxies.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,17 @@ export default (ts) =>
22
ts
33
? [
44
{
5-
fileName: 'overmind/index.ts',
65
code: `
7-
...
8-
9-
export const overmind = createOvermind(config, {
6+
const overmind = createOvermind(config, {
107
logProxies: false
118
})
129
`,
1310
},
1411
]
1512
: [
1613
{
17-
fileName: 'overmind/index.js',
1814
code: `
19-
...
20-
21-
export const overmind = createOvermind(config, {
15+
const overmind = createOvermind(config, {
2216
logProxies: false
2317
})
2418
`,

packages/overmind-website/examples/api/app_options_name.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,25 @@ export default (ts) =>
22
ts
33
? [
44
{
5-
fileName: 'overmind/index.ts',
65
code: `
7-
...
8-
9-
export const overmindA = createOvermind(configA, {
6+
const overmindA = createOvermind(configA, {
107
name: 'appA'
118
})
129
13-
export const overmindB = createOvermind(configB, {
10+
const overmindB = createOvermind(configB, {
1411
name: 'appB'
1512
})
1613
`,
1714
},
1815
]
1916
: [
2017
{
21-
fileName: 'overmind/index.js',
2218
code: `
23-
...
24-
25-
export const overmindA = createOvermind(configA, {
19+
const overmindA = createOvermind(configA, {
2620
name: 'appA'
2721
})
2822
29-
export const overmindB = createOvermind(configB, {
23+
const overmindB = createOvermind(configB, {
3024
name: 'appB'
3125
})
3226
`,

0 commit comments

Comments
 (0)