The service container is a way to manage dependencies and performing dependency injection. We have wrapped Inversify for our container. It is important to understand this concept as Varies core its built with the injection system.
You should for the most part always bind in a service provider, and we have provided one for you to get started in app/providers
.
Binding a interface to an implementation allows us to inject its implementation just based on the interface we want to use.
For instance, we have a DocumentationInterface
. Then we have a implementation of that interface, lets say VarieDocumentationService
.
Now we can resolve DocumentationService
to VarieDocumentationService.
this.app.bind <
DocumentationInterface >
("DocumentationService", VarieDocumentationService);
Within your service provider you have access to this.app
which is your app instance and can bind things to it. We are able to bind and resolve with the app
object.
this.app.value("$searchService", () => {
return new SearchService(new SomeSearchClass());
});
We also can bind a singleton instance so we may only want to resolve once.
this.app.singleton("$searchService", () => {
return new SearchService(new SomeSearchClass());
});
Dependency Injection documentation.
Varie registers some services that help boot the application. And are available to you to help development.
formService
: FormshttpService
: Http RequestsstateService
: State ManagementalertService
: AlertsconfigService
: ConfigurationcookieService
: CookiesstorageService
: StorageroutingService
: RoutingvalidationService
: Validation