Skip to content

Commit fd3022a

Browse files
Merge pull request cerebral#93 from cerebral/stringifyResultFix
fix(overmind): prevent hot reloading from messing up the app
2 parents 5bcda51 + a0ba508 commit fd3022a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

packages/node_modules/overmind/src/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ export type ActionCallback<App> = (action: TActionCreator<App>) => any
227227
CLASS TYPES
228228
*/
229229

230+
const hotReloadingCache = {}
231+
230232
export default class App<
231233
Config extends Configuration,
232234
EvalConfig extends TConfig<Config>
@@ -245,6 +247,13 @@ export default class App<
245247
}
246248
state: EvalConfig['state']
247249
constructor(configuration: Config, options: Options = {}) {
250+
const name = options.name || 'MyApp'
251+
252+
if (hotReloadingCache[name]) {
253+
return hotReloadingCache[name]
254+
} else {
255+
hotReloadingCache[name] = this
256+
}
248257
/*
249258
Mutate module functions into module objects
250259
*/

packages/node_modules/overmind/src/internalTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type SubType<Base, Condition> = Pick<
1616
>
1717

1818
export type Options = {
19+
name?: string
1920
devtools?: string
2021
}
2122

0 commit comments

Comments
 (0)