UNPKG

@ng-util/lazy

Version:

Lazy load javascript, css resources for Angular.

49 lines (48 loc) 1.5 kB
import { Observable } from 'rxjs'; import * as i0 from "@angular/core"; export type NuLazyResourcesType = 'script' | 'style'; export interface NuLazyResources { path: string; type: NuLazyResourcesType; /** * 回调名称 */ callback?: string; } export interface NuLazyResult { path: string; status: 'ok' | 'error' | 'loading'; type?: NuLazyResourcesType; error?: {}; } export declare class NuLazyService { private readonly doc; private list; private cached; private _notify; private fixPaths; /** * Monitor for the finished of `paths` * * - It's recommended to pass the value in accordance with the `load()` method */ monitor(paths?: string | Array<string | NuLazyResources>): Observable<NuLazyResult[]>; clear(): void; /** * Load the specified resources, includes `.js`, `.css` * * - The returned Promise does not mean that it was successfully loaded * - You can monitor load is success via `monitor()` */ load(paths: string | Array<string | NuLazyResources>): Promise<NuLazyResult[]>; loadScript(path: string, options?: { innerContent?: string; callback?: string; }): Promise<NuLazyResult>; loadStyle(path: string, options?: { rel?: string; innerContent?: string; }): Promise<NuLazyResult>; static ɵfac: i0.ɵɵFactoryDeclaration<NuLazyService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<NuLazyService>; }