distinctUntilChanged
signature: distinctUntilChanged(compare: function): Observable
Example 1: distinctUntilChanged with basic values
Example 2: distinctUntilChanged with objects
import { from } from 'rxjs/observable/from';
//Objects must be same reference
const myArrayWithDuplicateObjects = from([
sampleObject,
sampleObject,
sampleObject
//only out distinct objects, based on last emitted value
const nonDistinctObjects = myArrayWithDuplicateObjects
.pipe(distinctUntilChanged())
//output: 'DISTINCT OBJECTS: {name: 'Test'}
.subscribe(val => console.log('DISTINCT OBJECTS:', val));
Additional Resources