Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theAlgorithmist/0effc34344fefe76161538f479de5564 to your computer and use it in GitHub Desktop.
Save theAlgorithmist/0effc34344fefe76161538f479de5564 to your computer and use it in GitHub Desktop.
Lazy-load PIC Component
private async __loadComponent(): Promise<any>
{
let factory: ComponentFactory<IPointInCircle>;
if (this.picContainer) {
this.picContainer.clear();
}
// lazy-load the required component based on the algorithm id
switch (this.algorithm)
{
case 1:
const {Pic1Component} = await import('./components/point-in-circle-1/pic-1.component');
factory = this._compFactoryResolver.resolveComponentFactory(Pic1Component);
this.ComponentInstance = this.picContainer.createComponent(factory, null, this._injector);
this.render = RenderTargetEnum.CANVAS;
break;
case 2:
const {Pic2Component} = await import('./components/point-in-circle-2/pic-2.component');
factory = this._compFactoryResolver.resolveComponentFactory(Pic2Component);
this.ComponentInstance = this.picContainer.createComponent(factory, null, this._injector);
this.render = RenderTargetEnum.SVG;
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment