Beta (still building)

distinct

distinct operator only returns the emits value with compared values is distinct from previous.

Definition

distinct(keySelector?)

keySelector?: is a function to select which value you want to check

Example: distinct without arguments

import { interval, of } from 'rxjs';
import { distinct, concatMap, delay } from 'rxjs/operators';

const values = [0, 0, 1, 1, 2, 3, 1, 1]
const source$ = of(...values).pipe(
  concatMap( i => of(i).pipe(delay(1000)))
)

const result$ = source$.pipe(distinct());

Example: distinct with keySelector

import { of } from 'rxjs';
import { distinct, concatMap, delay, map } from 'rxjs/operators';

const values = [
  {name: 'Foo'},
  {name: 'Foo'},
  {name: 'Bar'},
  {name: 'Fiz'},
];
const source$ = of(...values).pipe(concatMap( i => of(i).pipe(delay(1000))))

const result$ = source$.pipe(
  distinct((v) => v.name),
  map(value => value.name),
);

Official Doc: rxjs.distinct