@cisstech/nge
Version:
NG Essentials is a collection of libraries for Angular developers.
43 lines (42 loc) • 1.74 kB
TypeScript
import { Observable } from 'rxjs';
import * as i0 from "@angular/core";
export declare class ResourceLoaderConfig {
/**
* If true, the document.baseURI will be used to build the url of the resource to load if the url is relative.
*/
useDocumentBaseURI?: boolean;
}
/**
* An array of [type, url, attributes] tuple where:
* - `type` is the type of an asset to load `script`| `style`
* - `url` is the url to a style/script to load
* - `attributes` is a map of optional attributes to add to the element.
*/
declare type ResourceInfo = ['style' | 'script', string, Record<string, string>?];
/**
* Services that dynamically inject scripts and styles elements to the DOM.
*/
export declare class ResourceLoaderService {
private readonly document;
private readonly config;
private readonly requests;
waitForPendings(): Promise<void>;
/**
* Injects styles and scripts from given urls to the head of the DOM.
* This method loads assets from same url once and the assets are
* loaded in the same order that given.
* @param resources Resources to load.
*/
loadAllSync(resources: ResourceInfo[]): Observable<ResourceInfo[]>;
/**
* Injects styles and scripts from given urls to target place in DOM
* This method loads style and script from same url once.
* @param resources Resources to load.
*/
loadAllAsync(resources: ResourceInfo[]): Observable<ResourceInfo[]>;
private createRequests;
static ɵfac: i0.ɵɵFactoryDeclaration<ResourceLoaderService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<ResourceLoaderService>;
}
export declare const ResourceLoaderConfigProvider: (config: Partial<ResourceLoaderConfig>) => any;
export {};