Skip to content
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

Subject state information methods & bounded ReplaySubject termination #2470

Merged
merged 2 commits into from
Jan 28, 2015

Conversation

akarnokd
Copy link
Member

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.
  • Each subject has hasCompleted, hasThrowable and getThrowable methods, however, I can't add them to Subject because that would be an incompatible API change.
  • Where applicable, getValue and getThrowable return null instead of throwing exceptions so users are encouraged to call hasXXX methods beforehand.
  • There was a chaining bug in the bounded ReplaySubject: because the terminal value was added after a potential pruning, the node links could get broken and concurrent replays might not have seen the terminal value.
  • Since ReplaySubject can have multiple values, I've added size(), hasAnyValue() (isEmpty is taken) and getValues() methods to make a snapshot of the current buffer contents whether or not the ReplaySubject has terminated (the usual toList() would wait until the subject has terminated).
  • The unrelated 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.

@akarnokd
Copy link
Member Author

I'm merging this: changes are either internal or annotated with experimental on final classes.

akarnokd added a commit that referenced this pull request Jan 28, 2015
Subject state information methods & bounded ReplaySubject termination
@akarnokd akarnokd merged commit ccada81 into ReactiveX:1.x Jan 28, 2015
@akarnokd akarnokd deleted the SubjectAdditionalMethods branch January 28, 2015 14:48
@benjchristensen benjchristensen mentioned this pull request Feb 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant