You need to sign in or sign up before continuing.
Commit 3bb9cf01 authored by nanahira's avatar nanahira

fix

parent ab5a0c05
import { Middleware, MiddlewareNext, MiddlewareResult } from './types';
import { Middleware, MiddlewareResult } from './types';
import { AnyClass, ClassType } from '../types';
import { DynamicMiddlewareDispatcher } from './dynamic-middleware-dispatcher';
......@@ -80,7 +80,7 @@ export class ProtoMiddlewareDispatcher<
for (const cls of chain) {
const mws = this.middlewareProtoMapPrior.get(cls);
if (mws) {
result.push(...mws);
result.push(...[...mws].reverse());
}
}
......
......@@ -13,7 +13,15 @@ describe('ProtoMiddlewareDispatcher', () => {
d.middleware(
Base,
async (x, inst, next) => {
order.push('base:prior');
order.push('base:prior1');
return next();
},
true,
);
d.middleware(
Base,
async (x, inst, next) => {
order.push('base:prior2');
return next();
},
true,
......@@ -26,6 +34,10 @@ describe('ProtoMiddlewareDispatcher', () => {
},
true,
);
d.middleware(Sub, async (x, inst, next) => {
order.push('sub:normal0');
return next();
});
d.middleware(Sub, async (x, inst, next) => {
order.push('sub:normal');
expect(inst).toBeInstanceOf(Sub);
......@@ -47,8 +59,10 @@ describe('ProtoMiddlewareDispatcher', () => {
sub.value = 5;
const res = await d.dispatch(3, sub);
expect(order).toEqual([
'base:prior',
'base:prior2',
'base:prior1',
'sub:prior',
'sub:normal0',
'sub:normal',
'base:normal',
]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment