web application - mindsers/yabf GitHub Wiki

WebApplication (class)

class WebApplication extends AbstractApplication {
  constructor(injectorService: InjectorService, routerService: RouterService, loggerService: LoggerService)

  static createInstance(): WebApplication

  provide<C>(className: InjectionType<C>): void
  provide<C>(className: InjectionClass<C>, dependencies?: InjectionSelector<any>[]): void
  declare<C extends Controller>(className: InjectionClass<C>, dependencies: InjectionSelector<any>[] = [])
  start(): void
}

The WebApplication class extends AbstractApplication class.

Description

An implementation of Application designed for the web. Add support for Controllers, routing...

Constructor

Initialize WebApplication instance.

constructor(injectorService: InjectorService, routerService: RouterService, loggerService: LoggerService)

Parameters

  • injectorService: the service that have the responsibility to create and inject objects.
  • routerService: the service that have the responsibility to resolve routes and call right controllers.
  • loggerService: the service that have the responsibility to write debug logs depending on configuration.

Methods

# provide()

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

Parameters

  • 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.

Returns

void: This method returns nothing.

# declare()

Register a controller inside of the application. Work as provide method but registered classes are not in singleton pattern.

declare<C extends Controller>(className: InjectionClass<C>, dependencies: InjectionSelector<any>[] = [])

Parameters

  • 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.

Returns

void: This method returns nothing.

# start()

Launch the application. This method acts like a classical main function.

Paramters

No parameters.

Returns

void: This method returns nothing.

# createInstance()

Static factory method which is responsible to create a new instance of WebApplication if no one is found in the dependency injector scope. If an instance already exists, it will be returned.

static createInstance(): WebApplication

Parameters

No parameters.

Returns

WebApplication: New or existing instance of WebApplication.

⚠️ **GitHub.com Fallback** ⚠️