Subject state information methods & bounded ReplaySubject termination #2470
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix.
This PR aims to support the requests in #2331 and #1897 by adding methods to the (final) subject classes that let developers access in-flight state in a snapshot fashion.
This may be considered safe API change because all subject classes were final already so adding extra methods won't break anyone's code (and we will be careful with our Observable in the future).
NotificationLite
is now extended with two missing value checks: isNull and isNext.hasCompleted
,hasThrowable
andgetThrowable
methods, however, I can't add them toSubject
because that would be an incompatible API change.getValue
andgetThrowable
returnnull
instead of throwing exceptions so users are encouraged to call hasXXX methods beforehand.ReplaySubject
can have multiple values, I've addedsize()
,hasAnyValue()
(isEmpty is taken) andgetValues()
methods to make a snapshot of the current buffer contents whether or not theReplaySubject
has terminated (the usual toList() would wait until the subject has terminated).OperatorMergeTest.testConcurrency
hangs for me for some reason without activity (either a buffer bug or a merge bug is in play there). I've added a timeout so it doesn't stop the other tests.