##// END OF EJS Templates
corrected code to support ts strict mode...
corrected code to support ts strict mode safe.ts - more tight typings - added notImplemented stub function - added fork funtion - added keys function (like Object.keys but extracts keys type) - added isKeyof typeguard - added 'primitive' union type added EventProvider for the observable

File last commit:

r115:691199f665e0 ioc ts support
r115:691199f665e0 ioc ts support
Show More
FactoryServiceDescriptor.ts
22 lines | 802 B | video/mp2t | TypeScriptLexer
/ src / main / ts / di / FactoryServiceDescriptor.ts
import { ServiceDescriptor, ServiceDescriptorParams } from "./ServiceDescriptor";
import { argumentNotNull, oid } from "../safe";
import { ActivationType } from "./interfaces";
export interface FactoryServiceDescriptorParams<S, T, P extends any[]> extends ServiceDescriptorParams<S, T, P> {
factory: (...args: P) => T;
}
export class FactoryServiceDescriptor<S, T, P extends any[]> extends ServiceDescriptor<S, T, P> {
constructor(opts: FactoryServiceDescriptorParams<S, T, P>) {
super(opts);
argumentNotNull(opts && opts.factory, "opts.factory");
// bind to null
this._factory = (...args) => opts.factory.apply(null, args as any);
if (opts.activation === ActivationType.Singleton) {
this._cacheId = oid(opts.factory);
}
}
}