Throttle(Time) interval difference between v6 & v7 when trailing=true
fatsu opened this issue · 0 comments
Describe the bug
Throttle(Time) behavior is significantly different in v7 compared to v6 when 'trailing=true'.
In v6, only the triggering event/value from the source observable started a throttling interval. Now, in v7, the emitted trailing value also starts a new interval (acting as leading?).
This means that the throttling intervals for a given source-stream / (time-)interval will be different depending on how 'trailing' has been set.
Given the changed spec file (throttleTime-spec.ts) this might be wanted behavior, but I cannot seems to find this in the docs, nor is it mentioned as a Breaking Change.
Given the current behaviour, the image shown on the ThrottleTime doc page is no longer correct... 'C' value will no longer be emitted, but there will be 2 'X' value emissions instead.
Expected behavior
The same behavior as in v6, or f this is wanted behavior, clear documentation.
Reproduction code
// TEST (trailing)
const source /* */ = 'A-----B--C--DE------';
// throttling_v7_1 = '----| ';
// throttling_v7_2 = ' ----| ';
// throttling_v7_3 = ' ----| ';
// throttling_v7_4 = ' ----| ';
const result_v7 /* */ = '----A---B---D---E---';
// throttling_v6 = '----| ----| ----| ';
const result_v6 /* */ = '----A-----C-----E---';
const result$ = cold(source).pipe(
throttleTime(4, rxTest2, { leading: false, trailing: true })
)
// TEST (leading/trailing)
const source /* */ = 'A-----B--C--DE------';
// throttling_v7_1 = '----| ';
// throttling_v7_2 = ' ----| ';
// throttling_v7_3 = ' ----| ';
const result_v7 /* */ = 'A-----B---C---E-----';
// throttling_v6 = '----| ----| ----| ';
const result_v6 /* */ = 'A-----B---C-D---E---';
const result$ = cold(source).pipe(
throttleTime(4, rxTest3, { leading: true, trailing: true })
);
Reproduction URL
https://stackblitz.com/edit/rxjs-y882mh?file=index.html
Version
7.5.7
Environment
No response
Additional context
No response