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

distinct

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