Averos Custom Initializer

Aside from the Global Application Initializer, which is activated by default when importing averos core module, averos users can define their own application initializer that will be executed prior to the global application initializer.
Custom application initializers are a way to include specific user actions into your application, that are required to be available beforehand such as fetching application data from database, configuring global application parameters, preparing global configurations โ€ฆect.

One particular custom application initializer, will be created by the workflow command ng add @wiforge/averos, and which will be in charge of registering any custom business entity into the averos framework context in order to make their entities metadata available to the framework beforehand.

A custom application initializer would look like this:

@Injectable({
  providedIn: 'root'
})
export class ApplicationInitializerService {

  private registeredEntities: Array<any> = 
                            [
                                Entity1.instanceMetadata(), 
                                Entity2.instanceMetadata(),
                                Entity3.instanceMetadata(),
                                Entity4.instanceMetadata(),
                                Entity5.instanceMetadata(),
                                Entity6.instanceMetadata()
                            ];

  constructor(private viewLayoutService: ViewLayoutService) {}

  initialize(): Promise<any> {
          const registerEntitiesPromise = this.viewLayoutService.registerEntitiesViewLayouts(this.registeredEntities);
          const asyncInitPromises: Promise<any>[] = [registerEntitiesPromise];
          return Promise.all(asyncInitPromises);// Wait for all promises to execute
  }
}

๐Ÿ”– Note that averos-entity workflow command will automatically create and register an entity, for you, in the averos framework context.