Skip to content

Commit

Permalink
fix(overmind): correctly pass operatorId on last flush of operators
Browse files Browse the repository at this point in the history
  • Loading branch information
christianalfoni committed Dec 28, 2018
1 parent 3602357 commit 2d8a845
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions packages/node_modules/overmind/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ export class Overmind<Config extends Configuration> implements Configuration {
this.trackEffects(this.effects, execution)
),
(err, finalContext) => {
this.eventHub.emit(
EventType.ACTION_END,
finalContext.execution
)
this.eventHub.emit(EventType.ACTION_END, {
...finalContext.execution,
operatorId: finalContext.execution.operatorId - 1,
})
if (err) reject(err)
else resolve(finalContext.value)
}
Expand Down Expand Up @@ -767,9 +767,21 @@ export function action<Input, Config extends Configuration = TheConfig>(
mutationTree.onMutation((mutation) => {
context.execution.emit(EventType.MUTATIONS, {
...context.execution,
operatorId: context.execution.operatorId,
mutations: makeStringifySafeMutations([mutation]),
})
setTimeout(() => {
const flushData = context.proxyStateTree.flush(true)
if (flushData.mutations.length) {
context.execution.send({
type: 'flush',
data: {
...context.execution,
...flushData,
mutations: makeStringifySafeMutations(flushData.mutations),
},
})
}
})
})
}
const maybePromise: any = operation({
Expand Down

0 comments on commit 2d8a845

Please sign in to comment.