MCPcopy
hub / github.com/angular/angular / constructor

Method constructor

packages/core/src/event_emitter.ts:120–133  ·  view source on GitHub ↗
(isAsync: boolean = false)

Source from the content-addressed store, hash-verified

118 private readonly pendingTasks: PendingTasksInternal | undefined = undefined;
119
120 constructor(isAsync: boolean = false) {
121 super();
122 this.__isAsync = isAsync;
123
124 // Attempt to retrieve a `DestroyRef` and `PendingTasks` optionally.
125 // For backwards compatibility reasons, this cannot be required.
126 if (isInInjectionContext()) {
127 // `DestroyRef` is optional because it is not available in all contexts.
128 // But it is useful to properly complete the `EventEmitter` if used with `outputToObservable`
129 // when the component/directive is destroyed. (See `outputToObservable` for more details.)
130 this.destroyRef = inject(DestroyRef, {optional: true}) ?? undefined;
131 this.pendingTasks = inject(PendingTasksInternal, {optional: true}) ?? undefined;
132 }
133 }
134
135 emit(value?: any) {
136 const prevConsumer = setActiveConsumer(null);

Callers

nothing calls this directly

Calls 2

isInInjectionContextFunction · 0.90
injectFunction · 0.90

Tested by

no test coverage detected