wishthis/node_modules/rxjs/dist/esm5/internal/operators/distinct.js
2022-04-07 09:06:43 +02:00

17 lines
No EOL
786 B
JavaScript

import { operate } from '../util/lift';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { noop } from '../util/noop';
export function distinct(keySelector, flushes) {
return operate(function (source, subscriber) {
var distinctKeys = new Set();
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
var key = keySelector ? keySelector(value) : value;
if (!distinctKeys.has(key)) {
distinctKeys.add(key);
subscriber.next(value);
}
}));
flushes === null || flushes === void 0 ? void 0 : flushes.subscribe(createOperatorSubscriber(subscriber, function () { return distinctKeys.clear(); }, noop));
});
}
//# sourceMappingURL=distinct.js.map