decorators
const decorators: {
class: {
Mixins: (...constructors: any[]) => (derivedCtor: any) => void;
Singleton: <T>(type: T) => SingletonType;
};
function: {
AsyncSingleExecution: (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
CacheUntilResolved: (_target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
Debounce: (delay?: number) => (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
ImmutableArgs: (_target: any, _propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor;
Memoize: (_target: any, _key: string, descriptor: PropertyDescriptor) => void;
MemoizeAsync: (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
MemoizeSingleArgPrimitive: <T, R>(_target: any, _propertyKey: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => R>) => TypedPropertyDescriptor<(...args: any[]) => R>;
QueueTask: (_target: unknown, _key: string, descriptor: PropertyDescriptor) => void;
RetryAsync: (retries?: number, interval?: number, reThrowException?: boolean) => MethodDecorator;
Throttle: (delay?: number) => (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
};
};
Type Declaration
class
class: {
Mixins: (...constructors: any[]) => (derivedCtor: any) => void;
Singleton: <T>(type: T) => SingletonType;
};
class.Mixins
Mixins: (...constructors: any[]) => (derivedCtor: any) => void;
A decorator to mix multiple classes into a single class.
Parameters
constructors
...any[]
The constructors of the classes to be mixed in.
Returns
A class decorator that mixes the provided classes into the target class.
(derivedCtor: any) => void
Example
class A {
methodA() {
console.log('A');
}
}
class B {
methodB() {
console.log('B');
}
}
// Apply decorator
// @Mixins(A, B)
class C {}
const instance = new C();
instance.methodA(); // Outputs: 'A'
instance.methodB(); // Outputs: 'B'