-
Notifications
You must be signed in to change notification settings - Fork 26.6k
Closed as not planned
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimecore: inputs / outputsfeatureIssue that requests a new featureIssue that requests a new feature
Milestone
Description
Which @angular/* package(s) are relevant/related to the feature request?
core
Description
With the @Output
decorator, I used to check the observed
of the EventEmitter
(because it inherits Subject
) to enable/disable some features.
For example, <lu-select (clueChange)="..." />
would display a search bar in LuSelect
component but <lu-select />
would not.
This solution seems elegant as it avoid an additional input that would lead to unwanted cases:
- Both
<lu-select enableClue (clueChange)="..." />
and<lu-select />
would work <lu-select (clueChange)="..." />
would be useless because the search bar is not disabled becauseenableClue = false
<lu-select enableClue />
would be useless because the search bar is displayed, but nobody listen to its value
Proposed solution
Add a getter
property observed
in OutputEmitterRef
export class OutputEmitterRef<T> implements OutputRef<T> {
private listeners: Array<(value: T) => void>|null = null;
get observed(): boolean {
return !!this.listeners?.length;
}
//...
}
Alternatives considered
Replace existing usages of emitter.observed
by inputs.
javiermarinros, nivekcode, eneajaho, sfs-jyskebank-dk, pablotarga and 61 more
Metadata
Metadata
Assignees
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimecore: inputs / outputsfeatureIssue that requests a new featureIssue that requests a new feature