ng-dynamic-component
Version:
> Dynamic components with full life-cycle support for inputs and outputs
55 lines (50 loc) • 2.62 kB
JavaScript
import * as i0 from '@angular/core';
import { Injectable, NgModule } from '@angular/core';
import { ComponentIO } from 'ng-dynamic-component';
import { outputToObservable } from '@angular/core/rxjs-interop';
import { isObservable } from 'rxjs';
/** @internal */
class SignalComponentIO {
setInput(componentRef, name, value) {
componentRef.setInput(name, value);
}
getOutput(componentRef, name) {
const output = componentRef.instance[name];
if (isObservable(output)) {
return output;
}
if (this.isOutputSignal(output)) {
return outputToObservable(output);
}
throw new Error(`Component ${name} is not an output!`);
}
isOutputSignal(value) {
return value != null && typeof value['subscribe'] === 'function';
}
}
/** @nocollapse */ SignalComponentIO.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: SignalComponentIO, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
/** @nocollapse */ SignalComponentIO.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: SignalComponentIO });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: SignalComponentIO, decorators: [{
type: Injectable
}] });
/**
* Enables signal based inputs/outputs support for dynamically rendered components.
* Import once at the root of your application.
* @public
*/
class SignalComponentIoModule {
}
/** @nocollapse */ SignalComponentIoModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: SignalComponentIoModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
/** @nocollapse */ SignalComponentIoModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.3", ngImport: i0, type: SignalComponentIoModule });
/** @nocollapse */ SignalComponentIoModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: SignalComponentIoModule, providers: [{ provide: ComponentIO, useClass: SignalComponentIO }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: SignalComponentIoModule, decorators: [{
type: NgModule,
args: [{
providers: [{ provide: ComponentIO, useClass: SignalComponentIO }],
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { SignalComponentIoModule };
//# sourceMappingURL=ng-dynamic-component-signal-component-io.mjs.map