-
-
Notifications
You must be signed in to change notification settings - Fork 0
abstract application
abstract class AbstractApplication {
static createInstance<T extends AbstractApplication>(): T
constructor(injectorService: InjectorService)
provide<C>(className: InjectionType<C>): void
provide<C>(className: InjectionClass<C>, dependencies?: InjectionSelector<any>[]): void
abstract start(): void
protected abstract buildInstructions(): IBuildInstruction[]
}
It provides some of the common behavior that all applications have. Ensure that any type of application can use dependency injection.
Initialize AbstractApplication
instance.
constructor(injectorService: InjectorService)
-
injectorService
: the service that have the responsibility to create and inject objects.
Create an instance of the application. Automatically injects the YABF dependency injector in the application. If you don't want to use the default injector, you have to overwrite this method.
To correctly use this method you have to implement buildInstructions()
method below.
static createInstance<T extends AbstractApplication>(): T
No parameters.
An instance of an application. For WebApplication.createInstance()
you'll get an instance of WebApplication
.
Maybe TypeScript will type the return value as AbstractApplication
which is true but not as efficient as we want. To correct this you have to use the generic version like that WebApplication.createInstance<WebApplication>()
.
Register a class C
in the application to be used (created and injected) later.
provide<C>(className: InjectionType<C>): void
provide<C>(className: InjectionClass<C>, dependencies?: InjectionSelector<any>[]): void
-
className
: the class that will be registred. Typically a constructor (Class
) or a configuration object ({ identity: Class, useClass: Class }
). -
dependencies
: An array of constructor that wil be injected in the future instance.
This method returns nothing. void
Need to be implemented in child class. Launch the application. Child class have to explain here how to start the program just like a classical main
function.
No parameters.
This method returns nothing. void
Allow you to specify how to build a custom application.
protected abstract buildInstructions(): IBuildInstruction[]
No parameters.
Return an array of build instructions.
The first instruction must be about the application. Yabf injects the dependencies injector before injecting others of yours.