UNPKG

ngx-mfe

Version:

A library for working with MFE in Angular in a plugin-based approach and with Angular routing.

67 lines (66 loc) 3.08 kB
import { Type } from '@angular/core'; import { AsyncSubject } from 'rxjs'; import { RemoteComponentWithModule, RemoteComponent, StandaloneRemoteComponent } from '../interfaces'; import { ComponentWithNgModuleRef } from '../types'; import * as i0 from "@angular/core"; /** * Cache of the loaded micro-frontend apps. * * Main reasons to create cache: * 1) Avoid race condition, when same micro-frontend are requested twice or more times at the same time. * 2) Cache already loaded MFE component and dont make same request twice. */ export declare class RemoteComponentsCache { private readonly _map; /** * Register a new micro-frontend cache. * @param remoteComponent Mfe Remote Component */ register(remoteComponent: RemoteComponent): void; /** * Unregister a micro-frontend cache. * @param remoteComponent Mfe Remote Component */ unregister(remoteComponent: RemoteComponent): void; /** * Checks that specified micro-frontend app already registered. * @param remoteComponent Mfe Remote Component */ isRegistered(remoteComponent: RemoteComponent): boolean; /** * Set to cache ComponentWithNgModuleRef of micro-frontend. * @param remoteComponent Mfe Remote Component * @param value ComponentWithNgModuleRef for that micro-frontend */ setValue<TComponent, TModule>(remoteComponent: RemoteComponentWithModule, value: ComponentWithNgModuleRef<TComponent, TModule>): void; setValue<TComponent>(remoteComponent: StandaloneRemoteComponent, value: Type<TComponent>): void; /** * Sets the error that occurs in the loading and compiling micro-frontend. * @param remoteComponent Mfe Remote Component * @param error Error */ setError(remoteComponent: RemoteComponent, error: any): void; /** * Gets ComponentWithNgModuleRef or Component Class of the micro-frontend. * * --------------------- * Returns ComponentWithNgModuleRef of MFE for component with module, * or returns Component Class of MFE for standalone component. * @param remoteComponent Mfe Remote Component */ getValue<TComponent, TModule>(remoteComponent: RemoteComponentWithModule): Promise<ComponentWithNgModuleRef<TComponent, TModule>>; getValue<TComponent>(remoteComponent: StandaloneRemoteComponent): Promise<Type<TComponent>>; /** * Gets the AsyncSubject cache value from Map * @param remoteComponent Mfe Remote Component */ protected getCache<TComponent, TModule>(remoteComponent: RemoteComponentWithModule): AsyncSubject<ComponentWithNgModuleRef<TComponent, TModule>>; protected getCache<TComponent>(remoteComponent: StandaloneRemoteComponent): AsyncSubject<Type<TComponent>>; /** * Generates a cache key based on RemoteComponent * @param remoteComponent Mfe Remote Component */ protected generateKey(remoteComponent: RemoteComponent): string; static ɵfac: i0.ɵɵFactoryDeclaration<RemoteComponentsCache, never>; static ɵprov: i0.ɵɵInjectableDeclaration<RemoteComponentsCache>; }