@microsoft/fast-element/di.js > Registration

Registration variable

You can use the resulting Registration of any of the factory methods to register with the container.

Signature:

Registration: Readonly<{
    instance<T>(key: Key, value: T): Registration<T>;
    singleton<T extends Constructable>(key: Key, value: T): Registration<InstanceType<T>>;
    transient<T extends Constructable>(key: Key, value: T): Registration<InstanceType<T>>;
    callback<T>(key: Key, callback: ResolveCallback<T>): Registration<Resolved<T>>;
    cachedCallback<T>(key: Key, callback: ResolveCallback<T>): Registration<Resolved<T>>;
    aliasTo<T>(originalKey: T, aliasKey: Key): Registration<Resolved<T>>;
}>

Example

class Foo {}
const container = DI.createContainer();
container.register(Registration.instance(Foo, new Foo()));
container.get(Foo);