Reputation: 1040
I have a filter class that I inherit wherever I want filter functionality.
export class FilterUtil{
…
public extFilterSubject = new Subject<any>();
constructor(){
this.extFilterSubject
.pipe(map(event => event)
, debounceTime(300)
, distinctUntilChanged())
.subscribe((searchKeyword) => {
//filter logic here.
})
}
}
This works.
The thing I want to accomplish is to apply distinctUntilUnchanged conditionally. I have come across one of the cases where I don't want distinctUntilUnchanged operator.
I looked into the official docs for distinctUntilUnchanged. But I couldnot find anything relevant.
Thanks.
Upvotes: 0
Views: 1538
Reputation: 848
It can only compare current value with the last value emitted. If you would want to apply your own condition.
distinctUntilChanged((valueOne: any, valueTwo: any) => {
if (Your Condition) {
return true; // This means values are equal, it will not emit the current value
} else {
return false;// This means the values are different, so it will emit
}
})
Upvotes: 6