@dotglitch/ngx-lazy-loader
Version:
A hackable lazy loader for Angular components
147 lines (146 loc) • 4.71 kB
TypeScript
import { ViewContainerRef, ComponentRef, EventEmitter, AfterViewInit } from '@angular/core';
import { DialogRef } from '@angular/cdk/dialog';
import { NgxLazyLoaderService } from './ngx-lazy-loader.service';
import { NgxLazyLoaderConfig } from './types';
import * as i0 from "@angular/core";
export declare class NgxLazyLoaderComponent implements AfterViewInit {
private service;
private viewContainerRef;
dialog: DialogRef;
dialogArguments: any;
targetContainer: ViewContainerRef;
/**
* ! Here be dragons.
* Only the bravest of Adventurers can survive the battles below,
* and they must be trained and ready for the gruelling journey ahead.
* Many a soul has tried to best these Dragons, yet only one has
* succeeded since our founding.
*
* TL;DR -- Don't mess with this unless you know what you're doing.
* This is central to a ton of moving parts -- breaking it will
* cause more collateral damage than you may realize.
*/
private _id;
/**
* The id of the component that will be lazy loaded
*/
set id(data: string);
private _group;
set group(data: string);
get group(): string;
private _matchGroups;
private _inputs;
/**
* A map of inputs to bind to the child.
* Supports change detection. (May fail on deep JSON changes)
*
* ```html
* <lazy-loader component="MyLazyComponent"
* [inputs]="{
* prop1: true,
* prop2: false,
* complex: {
* a: true,
* b: 0
* }
* }"
* >
* </lazy-loader>
* ```
*/
set inputs(data: {
[key: string]: any;
});
private outputSubscriptions;
private _outputs;
/**
* A map of outputs to bind from the child.
* Should support change detection.
* ```html
* <lazy-loader component="MyLazyComponent"
* [outputs]="{
* prop3: onOutputFire
* }"
* >
* </lazy-loader>
* ```
*/
set outputs(data: {
[key: string]: Function;
});
/**
* Emits errors encountered when loading components
*/
componentLoadError: EventEmitter<any>;
/**
* Emits when the component is fully constructed
* and had it's inputs and outputs bound
* > before `OnInit`
*
* Returns the active class instance of the lazy-loaded component
*/
componentLoaded: EventEmitter<any>;
/**
* This is an instance of the component that is currently loaded.
*/
instance: any;
/**
* Container that provides the component data
*/
private targetModule;
/**
* Component definition
*/
private targetComponentFactory;
/**
* Active component container reference
*/
private targetComponentContainerRef;
private targetRef;
/**
* Reference to the component class instance
*/
private targetComponentInstance;
/**
* Subscription with true/false state on whether the distractor should be
*/
private distractorSubscription;
config: NgxLazyLoaderConfig;
private err;
private warn;
private log;
private loaderEmitter;
private clearLoader$;
private loaderSub;
showLoader: boolean;
isClearingLoader: boolean;
constructor(service: NgxLazyLoaderService, viewContainerRef: ViewContainerRef, dialog: DialogRef, dialogArguments: any);
private initialized;
ngAfterViewInit(): Promise<void | ComponentRef<any>>;
ngOnDestroy(clearAll?: boolean): void;
/**
* Bind the input values to the child component.
*/
private bindInputs;
/**
* Bind the output handlers to the loaded child component
*/
private bindOutputs;
/**
* Load the "Default" component (404) screen normally.
* This is shown when the component id isn't in the
* registry or otherwise doesn't match
*
* This
*/
private loadDefault;
/**
* Load the "Error" component.
* This is shown when we are able to resolve the component
* in the registry, but have some issue boostrapping the
* component into the viewContainer
*/
private loadError;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxLazyLoaderComponent, [null, { optional: true; }, { optional: true; }, { optional: true; }]>;
static ɵcmp: i0.ɵɵComponentDeclaration<NgxLazyLoaderComponent, "ngx-lazy-loader", never, { "id": "component"; "group": "group"; "inputs": "inputs"; "outputs": "outputs"; }, { "componentLoadError": "componentLoadError"; "componentLoaded": "componentLoaded"; }, never, never, true, never>;
}