Skip to content

Commit

Permalink
fix: implement awaitPromise capability
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain committed Sep 8, 2023
1 parent 05de75e commit e22b8fa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/helper/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ function dispatch<C>(
if (idx < middlewareList.length) {
const middleware = middlewareList[idx];

maybePromise = middleware({
const t = middleware({
...ctx,
proceed: () => {
return dispatch(middlewareList, idx + 1, stack, ctx);
},
proceed: () => dispatch(middlewareList, idx + 1, stack, ctx),
} as Context<C>);

if (middleware.awaitPromise) {
maybePromise = Promise.resolve(maybePromise);
maybePromise = Promise.resolve(t);
} else {
maybePromise = t;
}
} else if (ctx.proceed) {
maybePromise = ctx.proceed();
Expand Down

0 comments on commit e22b8fa

Please sign in to comment.