Commit 17dc75ff authored by nanahira's avatar nanahira

put decorateMethod into info

parent 20ed2d33
......@@ -57,9 +57,10 @@ export class RegistrarAspect<Ctx extends Context, T = any> {
const data = this.registrar.reflector.get('CordisRegister', this.obj, key);
if (!data) return;
const specificCtx = this.getScopeContext(ctx, key, extraView, false);
const view = { ...this.view, ...extraView };
const result = data.run(
{ ...this.view, ...extraView },
specificCtx,
view,
{ ctx: specificCtx, obj: this.obj, key, view },
extractObjectMethod(this.obj, key),
);
return {
......
......@@ -57,11 +57,18 @@ export namespace Registrar {
R = any,
> = (ctx: Ctx, param: P, ...args: A) => R;
export interface MethodResolveInfo<Ctx extends Context> {
ctx: Ctx;
obj: any;
key: string;
view: any;
}
export type MethodResolver<
Ctx extends Context,
A extends any[] = any[],
F extends (...args: any[]) => any = (...args: any[]) => any,
> = DecorateFunctionParamSingle<Ctx, F, A>;
> = (info: MethodResolveInfo<Ctx>, fun: F, ...args: A) => any;
export type MethodMeta<Ctx extends Context> = RegisterMeta<
MethodResolver<Ctx>,
......@@ -422,13 +429,13 @@ export class Registrar<Ctx extends Context> {
return {
UseEvent: this.decorateMethod(
'on',
(ctx, fun, event: keyof GetEvents<Ctx>, prepend?: boolean) =>
({ ctx }, fun, event: keyof GetEvents<Ctx>, prepend?: boolean) =>
ctx.on(event as any, fun, prepend),
),
UsePlugin: this.decorateMethod(
'plugin',
(
ctx,
{ ctx },
fun: (
...args: any[]
) => Awaitable<PluginRegistrar.PluginDefinition<Ctx>>,
......@@ -447,7 +454,7 @@ export class Registrar<Ctx extends Context> {
}
},
),
Apply: this.decorateMethod('apply', (ctx, fun) => fun()),
Apply: this.decorateMethod('apply', (info, fun) => fun()),
};
}
......
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