@eggjs/tegg-lifecycle
Version:
tegg lifecycle definition
22 lines (21 loc) • 1.65 kB
TypeScript
import type { EggPrototype, EggProtoImplClass, LifecycleContext, LifecycleHook, LifecycleHookName, LifecycleObject } from '@eggjs/tegg-types';
export declare class LifecycleUtil<T extends LifecycleContext, R extends LifecycleObject<T>> {
private lifecycleSet;
private objLifecycleSet;
registerLifecycle(lifecycle: LifecycleHook<T, R>): void;
deleteLifecycle(lifecycle: LifecycleHook<T, R>): void;
getLifecycleList(): LifecycleHook<T, R>[];
registerObjectLifecycle(obj: R, lifecycle: LifecycleHook<T, R>): void;
deleteObjectLifecycle(obj: R, lifecycle: LifecycleHook<T, R>): void;
clearObjectLifecycle(obj: R): void;
getObjectLifecycleList(obj: R): LifecycleHook<T, R>[];
objectPreCreate(ctx: T, obj: R): Promise<void>;
objectPostCreate(ctx: T, obj: R): Promise<void>;
objectPreDestroy(ctx: T, obj: R): Promise<void>;
static callPreCreate<T extends LifecycleContext, R extends LifecycleObject<T>>(lifecycle: LifecycleHook<T, R> | undefined, ctx: T, obj: R): Promise<void>;
static callPostCreate<T extends LifecycleContext, R extends LifecycleObject<T>>(lifecycle: LifecycleHook<T, R> | undefined, ctx: T, obj: R): Promise<void>;
static callPreDestroy<T extends LifecycleContext, R extends LifecycleObject<T>>(lifecycle: LifecycleHook<T, R> | undefined, ctx: T, obj: R): Promise<void>;
static setLifecycleHook(method: string, hookName: LifecycleHookName, clazz: EggProtoImplClass): void;
getLifecycleHook(hookName: LifecycleHookName, proto: EggPrototype): string | undefined;
static getStaticLifecycleHook(hookName: LifecycleHookName, clazz: EggProtoImplClass): string | undefined;
}