-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replay(bufferSize, time, TimeUnit) not working - truncate should be called with replay? #3917
Comments
True, replay starts from the current head which is only moved forward by Question is, do we want this behavior change and whether the current behavior is expected by unit tests? |
Good point. I think the current behavior is a conflict with the method description/purpose. So I'd say change, if not at least an update to the documentation. Maybe deprecate the current one? Being new to Rx I spent quite a while trying to figure out why this wasn't working. |
Also, could you recommend a workaround to achieve that behavior? Basically I wanted to do something like replay a network call within a specific time, and if it came out empty I'd repeat the call. |
You can timestamp values before it reaches the ReplaySubject then use skipWhile(n -> n.timestamp < now - maxAge). Otherwise, see #3918 for an updated ReplaySubject where stale data is skipped on subscription. |
Sorry, I completely forgot about this. I'll post an PR to replay() and see what it takes to skip old entries. |
See #4023 for a proposed fix for |
Closing via #4023. |
The buffer only gets truncated when a new item is added. So any subscribers will always receive that last emission even if it's older than the time-limit.
Here subscriber C is subbing after 30 secs so you'd expect the buffer to have truncated the last value since the time-limit is 5 secs.
This is the output:
The text was updated successfully, but these errors were encountered: