distinctUntilChanged
signature: distinctUntilChanged(compare: function): Observable
distinctUntilChanged(compare: function): ObservableOnly emit when the current value is different than the last.
Examples
// RxJS v6+
import { from } from 'rxjs';
import { distinctUntilChanged } from 'rxjs/operators';
// only output distinct values, based on the last emitted value
const source$ = from([1, 1, 2, 2, 3, 3]);
source$
.pipe(distinctUntilChanged())
// output: 1,2,3
.subscribe(console.log);Related Recipes
Additional Resources
Last updated
Was this helpful?