ReplaySubject windowTime behavior is maybe misinterpreted #7570
hansschenker
started this conversation in
Ideas / Feature request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Issue Summary
There is a potential mismatch between the documented and implemented behavior of
ReplaySubject
'swindowTime
parameter and the intuitive expectation set by Erik Meijer's original definition of reactive subjects.see Erik Meijer describing ReplaySubject Behavior: https://youtu.be/WKore-AkisY?si=0THPHML0KjGY6iJK&t=1687
Expected Behavior (Erik Meijer / Intuitive)
bufferSize
(count): Should keep the lastn
values.windowTime
: Should keep all values emitted within the lastwindowTime
milliseconds when a new subscriber subscribes.Actual RxJS Behavior
bufferSize
works as expected (last n values).windowTime
keeps each value in the buffer for up towindowTime
ms after it was emitted. Buffer is trimmed only on emission or subscription.windowTime
ms, but only those whose expiration (emitTime + windowTime
) is after the subscription time and that haven't already been trimmed.Example
Suppose values are emitted at t=0, t=1000, t=2000, t=3000, and
windowTime=2000
. If a subscriber arrives at t=3500:Request
ReplaySubject
and itswindowTime
parameter to explicitly state this behavior.Thanks for considering this clarification to help future users avoid
Beta Was this translation helpful? Give feedback.
All reactions