Skip to content

Commit 83b3984

Browse files
refactor(overmind): correctly implement run async
1 parent d430a50 commit 83b3984

File tree

1 file changed

+8
-10
lines changed
  • packages/node_modules/overmind/src

1 file changed

+8
-10
lines changed

packages/node_modules/overmind/src/index.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -648,17 +648,15 @@ export function run<Input, BaseContext = Context>(
648648
if (err) next(err)
649649
else {
650650
startDebugOperator('run', operation, context)
651-
const runNext = () => {
652-
const newContext = createContext(context, context.value)
653-
stopDebugOperator(newContext)
654-
next(null, newContext)
655-
}
656651
const result = operation(context)
657-
if (result instanceof Promise) {
658-
result.then(runNext).catch(next)
659-
} else {
660-
runNext()
661-
}
652+
const newContext = createContext(
653+
context,
654+
result instanceof Promise
655+
? result.then(() => context.value)
656+
: context.value
657+
)
658+
stopDebugOperator(newContext)
659+
next(null, newContext)
662660
}
663661
}
664662
instance[IS_PIPE] = true

0 commit comments

Comments
 (0)