Reputation: 4154
I have the following pipe:
{{ "value" | translationPipe | async }}
translationPipe {
constructor(otherService: OtherService, myService: MyService, _ref : ChangeDetectorRef) {
this.myService.myEventEmitter.subscribe(value -> {
_ref.markForCheck();
});
}
transform(value, args?) {
// this returns an api call observable
return this.otherService.doApiCall();
}
}
However when the event emitter outputs an event the value of the pipe is not reobtained.
Upvotes: 0
Views: 433
Reputation: 657781
Angular change detection checks the value and the parameters passed to a pipe for change. If they don't change, calling markForCheck()
is just a waste of CPU.
A workaround could be to use pure: false
and return the cached result until myEventEmitter
emits an event.
Upvotes: 1