.
This commit is contained in:
34
node_modules/rxjs/dist/esm/internal/operators/debounce.js
generated
vendored
Normal file
34
node_modules/rxjs/dist/esm/internal/operators/debounce.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import { operate } from '../util/lift';
|
||||
import { noop } from '../util/noop';
|
||||
import { createOperatorSubscriber } from './OperatorSubscriber';
|
||||
import { innerFrom } from '../observable/innerFrom';
|
||||
export function debounce(durationSelector) {
|
||||
return operate((source, subscriber) => {
|
||||
let hasValue = false;
|
||||
let lastValue = null;
|
||||
let durationSubscriber = null;
|
||||
const emit = () => {
|
||||
durationSubscriber === null || durationSubscriber === void 0 ? void 0 : durationSubscriber.unsubscribe();
|
||||
durationSubscriber = null;
|
||||
if (hasValue) {
|
||||
hasValue = false;
|
||||
const value = lastValue;
|
||||
lastValue = null;
|
||||
subscriber.next(value);
|
||||
}
|
||||
};
|
||||
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
|
||||
durationSubscriber === null || durationSubscriber === void 0 ? void 0 : durationSubscriber.unsubscribe();
|
||||
hasValue = true;
|
||||
lastValue = value;
|
||||
durationSubscriber = createOperatorSubscriber(subscriber, emit, noop);
|
||||
innerFrom(durationSelector(value)).subscribe(durationSubscriber);
|
||||
}, () => {
|
||||
emit();
|
||||
subscriber.complete();
|
||||
}, undefined, () => {
|
||||
lastValue = durationSubscriber = null;
|
||||
}));
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=debounce.js.map
|
||||
Reference in New Issue
Block a user