ayanami
Version:
A better way to react with state
18 lines (17 loc) • 742 B
JavaScript
import { InjectableFactory } from '@asuka/di';
import { createOrGetInstanceInScope, createScopeWithRequest } from './utils';
import { SameScope } from './same-scope-decorator';
export { SameScope, createScopeWithRequest };
export var TransientScope = Symbol('scope:transient');
export var SingletonScope = Symbol('scope:singleton');
export function getInstanceWithScope(constructor, scope) {
if (scope === void 0) { scope = SingletonScope; }
switch (scope) {
case SingletonScope:
return InjectableFactory.getInstance(constructor);
case TransientScope:
return InjectableFactory.initialize(constructor);
default:
return createOrGetInstanceInScope(constructor, scope);
}
}