Repository navigation
Replies: 1 comment
|
There isn't a general discarded-value notification in RxJS 7.8.2. A For import { of, filter, distinctUntilChanged } from 'rxjs';
const onDrop = (operator: string, value: number) =>
console.log('dropped by', operator, value);
of(1, 1, 2, 2, 3, 3).pipe(
filter(value => {
const keep = value >= 2;
if (!keep) onDrop('filter', value);
return keep;
}),
distinctUntilChanged((previous, current) => {
const same = previous === current;
if (same) onDrop('distinctUntilChanged', current);
return same;
}),
).subscribe(value => console.log('output', value));This outputs The other two need operator-specific handling:
If you need one consistent Checked the example and the debounce/exhaust timing behavior with RxJS 7.8.2; the example also passes TypeScript 5.9.3 strict checking. Keep the callbacks observational: throwing from one errors the stream, and feeding values back into the same source introduces reentrancy. |
Uh oh!
There was an error while loading. Please reload this page.
When pipeline includes operators like filter, debounce Time, distinctUntilChanged, exhaustMap etc, upper stream values will been ignored by these operators. I actually want to execute logic right after value is ignored, is there any general way to implement this?
All reactions