Closed
Description
Bug Report
Current Behavior
Reduced test case: https://github.com/OliverJAsh/rxjs-v7-buffer-regression
I have the following operator:
import * as RxJS from "rxjs";
import * as RxJSOperators from "rxjs/operators";
// Buffer the values and emit only after a particular time span has passed without another source
// emission.
// Like `bufferTime`, but uses debouncing instead of throttling.
// https://stackoverflow.com/questions/50515357/debounce-and-buffer-an-rxjs-subscription/50519552#50519552
export const bufferDebounce = (ms: number) => <T>(
source: RxJS.Observable<T>
): RxJS.Observable<T[]> =>
// The observable will have multiple subscribers, because it is used by both `buffer` and
// `debounceTime`. We want to share the execution.
source.pipe(
RxJSOperators.publish((published) =>
published.pipe(
RxJSOperators.buffer(published.pipe(RxJSOperators.debounceTime(ms)))
)
)
);
This test passes in v6 and v7.0.0-beta.4 but fails in v7.0.0-beta.5 and above:
it(
"works with observable that emits and completes immediately",
marbles((m) => {
const source$ = m.cold("(a|)");
const ms = m.time(" |");
const expected = " (1|)";
const actual$ = source$.pipe(bufferDebounce(ms));
m.expect(actual$).toBeObservable(expected, { 1: ["a"] });
})
);
The test fails with:
● bufferDebounce › works with observable that emits and completes immediately
expect(received).toStrictEqual(expected) // deep equality
- Expected - 10
+ Received + 0
Array [
Object {
"frame": 0,
"notification": Object {
"error": undefined,
- "kind": "N",
- "value": Array [
- "a",
- ],
- },
- },
- Object {
- "frame": 0,
- "notification": Object {
- "error": undefined,
"kind": "C",
"value": undefined,
},
},
]
I believe this is due to #5654 but I'm not sure if this is intentional.
Expected behavior
The test passes like it did before v7.0.0-beta.5.
Reproduction
See above
Metadata
Assignees
Labels
No labels
Activity