In my component i'm using an @Input
that is type of Observable
. In the view I'm using the | async
pipe to handle the subscribe and unsubscribe of the Observable stream.
In the component I'm trying to pipe
this Observable to perform some mutation on the stream. However the map function inside the pipe never gets triggered.
data.component.ts:
@Component({
selector: 'data',
template: `<div *ngFor="let item of (data$ | async)">{{item}}</div>`
})
export class DataComponent implements OnInit {
@Input()
data$: Observable<IData>;
constructor() {}
ngOnInit() {
this.data$
.pipe(
map(next => {
// do some data mutation
// never getting in here
})
)
}
}
Right now the map function inside the pipe never gets triggered and thus does not mutate the data as desired. The desired outcome would be that the data mutation happens inside the map function.
subscribe
, otherwise the you won't receive any items. – martindata$
?pipe()
method doesn't modify the chain "in-place" so you have to assign it to a different variable and then use| async
on that. – martinthis.mutatedData$ = this.data$
and thenthis.mutatedData$.pipe(map())
. In the view dothis.mutatedData$ | async
? Because that seems not to work either. – Nephi