Binder and Injector (aka Container) to handle (a)synchronous dependency management.
Bind an InjectableId to an asynchronous factory that will be invoked on demand when the object is needed. The factory should produce the needed value (asynchronously of course). NOTE: The container will not invoke any @PostConstruct present on the class, this is the responsibility of the factory. WARNING!!! The factory may not throw and must return a valid Promise (which can be pending, resolved, rejected, etc.).
Bind an InjectableId to a class (actually it's constructor). As a shortcut, you may use the class constructor as the 'id' (e.g. container.bindClass(A); ). The container will also invoke any @PostConstruct present on the class.
Bind an InjectableId to a constant value. Constants are by their very nature singleton, and are assumed to be error proof.
Bind an InjectableId to a synchronous factory that will be invoked on demand when the object is needed. The factory should produce the needed value NOTE: The container will not invoke any @PostConstruct present on the class, this is the responsibility of the factory.
Return an instance of <T> previously bound to 'id'.
Check to see if the existing InjectableId is known (aka has been bound). Error callbacks may wish to know if a particular InjectableId is available. Also the Binder's bindXXX calls always overwrite any previous bindings, so you may want to use this as a gate.
This method is not part of the Binding interface, because it is highly unusual. But that doesn't mean we can't imagine scenarios where you might require it.
awaits the asynchronous resolution of all dependencies in the tree for 'id'.
This essentially pre creates/loads all singleton InjectableIds currently known to the Binder. This may be helpful if you wish to use Injector.get on a dependency tree that has asynchronous singletons within the tree.
A Promise that resolves when all Singleton's have been resolved, OR rejects if one or more of the Singleton's failed to resolve. NOTE: Rejection does not occur until all Singleton resolutions have settled, and the rejection reason/err will be a Map<InjectableId, Error>
As implied by the name prefix, this is a factored out method invoked only by the 'resolve' method. It makes searching our parent (if it exists) easier (and quicker) IF our parent is a fellow instance of Container.
Generated using TypeDoc
Create a new Container, with an optional parent Injector which will be searched if any given InjectableId is not bound within this Container.