MCPcopy
hub / github.com/loopbackio/loopback-next / injectable

Function injectable

packages/context/src/binding-decorator.ts:67–90  ·  view source on GitHub ↗
(...specs: BindingSpec[])

Source from the content-addressed store, hash-verified

65 * configure the binding
66 */
67export function injectable(...specs: BindingSpec[]): ClassDecorator {
68 const templateFunctions = specs.map(t => {
69 if (typeof t === 'function') {
70 return t;
71 } else {
72 return asBindingTemplate(t);
73 }
74 });
75
76 return (target: Function) => {
77 const cls = target as Constructor<unknown>;
78 const spec: BindingMetadata = {
79 templates: [asClassOrProvider(cls), ...templateFunctions],
80 target: cls,
81 };
82
83 const decorator = InjectableDecoratorFactory.createDecorator(
84 BINDING_METADATA_KEY,
85 spec,
86 {decoratorName: '@injectable'},
87 );
88 decorator(target);
89 };
90}
91
92/**
93 * A namespace to host shortcuts for `@injectable`

Callers 15

extensionPointFunction · 0.90
lifeCycleObserverFunction · 0.90
MyServiceClass · 0.90
CalculatorServiceClass · 0.90
OtherServiceClass · 0.90
MyServiceProviderClass · 0.90
DatabaseServiceClass · 0.90
UserServiceClass · 0.90
ConfigProviderClass · 0.90
ConsoleLoggerClass · 0.90
FileLoggerClass · 0.90
MyServiceClass · 0.90

Calls 3

asBindingTemplateFunction · 0.90
asClassOrProviderFunction · 0.90
createDecoratorMethod · 0.45

Tested by

no test coverage detected