Parent HTML:
<ng-container *ngFor="let doc of documents">
<child [clickEvent]="eventSubject.asObservable()" [document]="doc"></child>
</ng-container>
Parent Class:
eventSubject: Subject<boolean> = new Subject<boolean>();
onclick(event) {
this.eventSubject.next(event)
}
Child Class:
@Input() keyEvent: Observable<boolean>;
this.keyEvent
.subscribe(res => {
console.log(res);
})
Because I bind the event inside an *ngFor, it sends the value as much as my array length. Its essential that I get the last or one value of the emitted in the observable. What can be done?
I tried using the take and last operators, but they complete the stream.