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'swindowTimeparameter 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 lastnvalues.windowTime: Should keep all values emitted within the lastwindowTimemilliseconds when a new subscriber subscribes.Actual RxJS Behavior
bufferSizeworks as expected (last n values).windowTimekeeps each value in the buffer for up towindowTimems after it was emitted. Buffer is trimmed only on emission or subscription.windowTimems, 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
ReplaySubjectand itswindowTimeparameter to explicitly state this behavior.Thanks for considering this clarification to help future users avoid
Beta Was this translation helpful? Give feedback.
All reactions