Rx.Observable.prototype.distinct([keySelector], [keySerializer])


Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer. Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.


  1. [keySelector] (Function): A function to compute the comparison key for each element.
  2. [keySerializer] (Function): Used to serialize the given object into a string for object comparison.


(Observable): An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.


Without key selector

With key selector