Commit 5709e827 authored by nanahira's avatar nanahira

middleware rxjs support

parent bcebb452
......@@ -107,7 +107,14 @@ export namespace DoRegister {
export const middleware = registry.define(
'middleware',
(prepend, ctx, obj, key) =>
ctx.middleware((session, next) => obj[key](session, next), prepend),
ctx.middleware(async (session, next) => {
const ret = await obj[key](session, next);
if (isObservable(ret)) {
return sessionRxToPromise(session, ret as Observable<string>);
} else {
return ret;
}
}, prepend),
);
export const event = registry.define('onEvent', (data, ctx, obj, key) =>
......
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