A decorator to request from Container that it resolve the annotated property dependency. For example:
@ AutoWired
class PersonService {
constructor (@ Inject creationTime: Date) {
this.creationTime = creationTime;
}
@ Inject
personDAO: PersonDAO;
creationTime: Date;
}
When you call:
let personService: PersonService = Container.get(PersonService);
// The properties are all defined, retrieved from the IoC Container
console.log('PersonService.creationTime: ' + personService.creationTime);
console.log('PersonService.personDAO: ' + personService.personDAO);
Decorator processor for Inject decorator on constructor parameters
Decorator processor for Inject decorator on properties
A decorator to tell the container that this class should instantiated by the given Provider. For example:
@ Provided({get: () => { return new PersonDAO(); }})
class PersonDAO {
}
Is the same that use:
Container.bind(PersonDAO).provider({get: () => { return new PersonDAO(); }});
The provider that will handle instantiations for this class.
A decorator to tell the container that this class should be used as the implementation for a given base class. For example:
class PersonDAO {
}
@ Provides(PersonDAO)
class ProgrammerDAO extends PersonDAO{
}
Is the same that use:
Container.bind(PersonDAO).to(ProgrammerDAO);
The base class that will be replaced by this class.
A decorator to tell the container that this class should be handled by the provided Scope. For example:
class MyScope extends Scope {
resolve(iocProvider:Provider, source:Function) {
console.log('created by my custom scope.')
return iocProvider.get();
}
}
@ Scoped(new MyScope())
class PersonDAO {
}
Is the same that use:
Container.bind(PersonDAO).scope(new MyScope());
The scope that will handle instantiations for this class.
A decorator to tell the container that this class should be handled by the Singleton Scope.
@ Singleton
class PersonDAO {
}
Is the same that use:
Container.bind(PersonDAO).scope(Scope.Singleton)
Utility function to validate type
Generated using TypeDoc
A decorator to tell the container that this class should its instantiation always handled by the Container.
An AutoWired class will have its constructor overriden to always delegate its instantiation to the IoC Container. So, if you write:
@ AutoWired class PersonService { @ Inject personDAO: PersonDAO; }
Any PersonService instance will be created by the IoC Container, even when a direct call to its constructor is called:
let PersonService = new PersonService(); // will be returned by Container, and all internal dependencies resolved.
It is the same that use:
Container.bind(PersonService); let personService: PersonService = Container.get(PersonService);