diff --git a/src/operator/distinct.ts b/src/operator/distinct.ts index 406335863f..9cc1fcd8e7 100644 --- a/src/operator/distinct.ts +++ b/src/operator/distinct.ts @@ -9,12 +9,15 @@ import { ISet, Set } from '../util/Set'; /** * Returns an Observable that emits all items emitted by the source Observable that are distinct by comparison from previous items. - * If a comparator function is provided, then it will be called for each item to test for whether or not that value should be emitted. - * If a comparator function is not provided, an equality check is used by default. - * As the internal HashSet of this operator grows larger and larger, care should be taken in the domain of inputs this operator may see. - * An optional parameter is also provided such that an Observable can be provided to queue the internal HashSet to flush the values it holds. - * @param {function} [keySelector] optional function to select which value you want to check as distinct - * @param {function} [compare] optional comparison function called to test if an item is distinct from previous items in the source. + * If a keySelector function is provided, then it will project each value from the source observable into a new value that it will + * check for equality with previously projected values. If a keySelector function is not provided, it will use each value from the + * source observable directly with an equality check against previous values. + * In JavaScript runtimes that support `Set`, this operator will use a `Set` to improve performance of the distinct value checking. + * In other runtimes, this operator will use a minimal implementation of `Set` that relies on an `Array` and `indexOf` under the + * hood, so performance will degrade as more values are checked for distinction. Even in newer browsers, a long-running `distinct` + * use might result in memory leaks. To help alleviate this in some scenarios, an optional `flushes` parameter is also provided so + * that the internal `Set` can be "flushed", basically clearing it of values. + * @param {function} [keySelector] optional function to select which value you want to check as distinct. * @param {Observable} [flushes] optional Observable for flushing the internal HashSet of the operator. * @return {Observable} an Observable that emits items from the source Observable with distinct values. * @method distinct