ayanami
Version:
A better way to react with state
14 lines (13 loc) • 579 B
JavaScript
export const SameScopeMetadataKey = Symbol('SameScopeInjectionParams');
export const SameScope = () => (
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
target, _propertyKey, parameterIndex) => {
let sameScopeInjectionParams = [];
if (Reflect.hasMetadata(SameScopeMetadataKey, target)) {
sameScopeInjectionParams = Reflect.getMetadata(SameScopeMetadataKey, target);
}
else {
Reflect.defineMetadata(SameScopeMetadataKey, sameScopeInjectionParams, target);
}
sameScopeInjectionParams[parameterIndex] = true;
};