Skip to content

Commit 8be97fe

Browse files
fix(overmind): allow flush when parent execution is done running
1 parent ba36881 commit 8be97fe

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

packages/node_modules/overmind/src/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ export class Overmind<ThisConfig extends IConfiguration>
306306
proxyStateTree.getMutationTree().flush(true)
307307
})
308308
eventHub.on(EventType.ACTION_END, (execution) => {
309-
if (!execution.parentExecution) proxyStateTree.getMutationTree().flush()
309+
if (!execution.parentExecution || !execution.parentExecution.isRunning)
310+
proxyStateTree.getMutationTree().flush()
310311
})
311312

312313
let nextTick
@@ -332,7 +333,10 @@ export class Overmind<ThisConfig extends IConfiguration>
332333
}
333334
})
334335
eventHub.on(EventType.ACTION_END, (execution) => {
335-
if (!execution.parentExecution) {
336+
if (
337+
!execution.parentExecution ||
338+
!execution.parentExecution.isRunning
339+
) {
336340
const flushData = execution.flush()
337341

338342
if (this.devtools && flushData.mutations.length) {
@@ -501,6 +505,7 @@ export class Overmind<ThisConfig extends IConfiguration>
501505
effects: this.trackEffects(this.effects, execution),
502506
},
503507
(err, finalContext) => {
508+
execution.isRunning = false
504509
finalContext &&
505510
this.eventHub.emit(EventType.ACTION_END, {
506511
...finalContext.execution,

packages/overmind-website/src/components/Guides/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ const Guides: SFC = () => {
1010
return <Loader />
1111
}
1212

13-
console.log(state.guides)
14-
1513
return (
1614
<div className={styles.wrapper}>
1715
{state.guides.map((guide) => (

packages/overmind-website/src/overmind/onInitialize.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { OnInitialize } from 'overmind'
22

3-
const onInitialize: OnInitialize = async ({ effects, state }, app) => {
3+
const onInitialize: OnInitialize = async ({ effects, state, actions }) => {
44
state.showViewHelp = !effects.storage.get('theme')
55

6-
effects.router.route('/', app.actions.openHome)
7-
effects.router.route('/guides', app.actions.openGuides)
8-
effects.router.route('/guides/:type/:title', app.actions.openGuide)
9-
effects.router.route('/videos', app.actions.openVideos)
10-
effects.router.route('/videos/:title', app.actions.openVideo)
11-
effects.router.route('/api/:title', app.actions.openApi)
6+
effects.router.route('/', actions.openHome)
7+
effects.router.route('/guides', actions.openGuides)
8+
effects.router.route('/guides/:type/:title', actions.openGuide)
9+
effects.router.route('/videos', actions.openVideos)
10+
effects.router.route('/videos/:title', actions.openVideo)
11+
effects.router.route('/api/:title', actions.openApi)
1212
effects.router.redirect('/api', '/api/action')
1313

1414
effects.router.start()

0 commit comments

Comments
 (0)