Referencedistinct
Reference · 57
distinct
distinct
Passes only values with a key not seen for the whole subscription.
Signature
distinct(keySelector?: (value: T) => K): MonoTypeOperatorFunction
What it does
Keeps a Set of keys already seen. If a key has appeared before, the value is dropped; if it's new, it passes on.
When to use
Removing duplicate ids from an event list, keeping the first unique values, guarding against repeat clicks on the same entity.
Gotcha
The Set grows until the stream completes. For infinite streams use the flushes parameter, or distinctUntilChanged if you only need to compare neighboring values.
See also
distinctUntilChanged, distinctUntilKeyChanged
script.ts
CONSOLE · Console output
Hit Run to see the result...