Skip to content

Commit 2d8a845

Browse files
fix(overmind): correctly pass operatorId on last flush of operators
1 parent 3602357 commit 2d8a845

File tree

1 file changed

+17
-5
lines changed
  • packages/node_modules/overmind/src

1 file changed

+17
-5
lines changed

packages/node_modules/overmind/src/index.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ export class Overmind<Config extends Configuration> implements Configuration {
246246
this.trackEffects(this.effects, execution)
247247
),
248248
(err, finalContext) => {
249-
this.eventHub.emit(
250-
EventType.ACTION_END,
251-
finalContext.execution
252-
)
249+
this.eventHub.emit(EventType.ACTION_END, {
250+
...finalContext.execution,
251+
operatorId: finalContext.execution.operatorId - 1,
252+
})
253253
if (err) reject(err)
254254
else resolve(finalContext.value)
255255
}
@@ -767,9 +767,21 @@ export function action<Input, Config extends Configuration = TheConfig>(
767767
mutationTree.onMutation((mutation) => {
768768
context.execution.emit(EventType.MUTATIONS, {
769769
...context.execution,
770-
operatorId: context.execution.operatorId,
771770
mutations: makeStringifySafeMutations([mutation]),
772771
})
772+
setTimeout(() => {
773+
const flushData = context.proxyStateTree.flush(true)
774+
if (flushData.mutations.length) {
775+
context.execution.send({
776+
type: 'flush',
777+
data: {
778+
...context.execution,
779+
...flushData,
780+
mutations: makeStringifySafeMutations(flushData.mutations),
781+
},
782+
})
783+
}
784+
})
773785
})
774786
}
775787
const maybePromise: any = operation({

0 commit comments

Comments
 (0)