When it comes to creating components, I've found it quite easy to use property binding for inputs with multiple options available like input(). However, when dealing with component outputs, it can be a bit complicated as there's only one option using output(). Typically, this involves creating an EventEmitter and having interested components subscribe to it. Is there a simpler way?
It would be great to have a solution that doesn't require subscriptions and EventEmitters.
Here's an example of what I'm referring to:
export class PriceQuoterComponent {
@Output() lastPrice = new EventEmitter<PriceQuote>();
priceQuote: PriceQuote;
constructor() {
interval(2000)
.subscribe(data => {
this.priceQuote = {
stockSymbol: 'IBM',
lastPrice: 100 * Math.random()
};
this.lastPrice.emit(this.priceQuote);})
}