Skip to content

clarify behaviour of groupBy in javadoc #3584

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

Merged
merged 1 commit into from
Jan 11, 2016

Conversation

davidmoten
Copy link
Collaborator

As discussed in #3411, some clarification of the behaviour of groupBy looks necessary re its behaviour when the GroupedObservable terminates early (for example has .first() applied to it). See also #3581.

I also took the liberty of recommending ignoreElements instead of take(0) for the section in the javadoc that recommends how to ignore emissions because the take(0) approach would have more overhead (every emission from source would prompt the emission of a new GroupedObservable) than the ignoreElements approach.

Once this is accepted I'll look to submit a PR with groupByOnce (mentioned in #3411).

@davidmoten
Copy link
Collaborator Author

Corrected the documentation that said resubscription occurs when it is rather a new GroupedObservable is emittted for a group.

@@ -5577,14 +5577,16 @@ public final void forEach(final Action1<? super T> onNext, final Action1<Throwab

/**
* Groups the items emitted by an {@code Observable} according to a specified criterion, and emits these
* grouped items as {@link GroupedObservable}s, one {@code GroupedObservable} per group.
* grouped items as {@link GroupedObservable}s. If a {@code GroupedObservable}
* terminates before the source terminates then the next emission by the source with the same key as the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GroupedObservable allows only a single Subscriber during its lifetime and if this Subscriber unsubscribes before the main source terminates, the next emission by the main source having the same key will trigger a new GroupedObservable emission.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @akarnokd, that does add information. I'll use that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice that GroupedObservable itself doesn't have a single Subscriber restriction but certainly the GroupedObservable emitted by groupBy does have this property. I'll rejig the wording to get this across.

@davidmoten
Copy link
Collaborator Author

Incorporated @akarnokd suggestion

@akarnokd
Copy link
Member

👍

@zsxwing
Copy link
Member

zsxwing commented Jan 11, 2016

👍

I also took the liberty of recommending ignoreElements instead of take(0) for the section in the javadoc that recommends how to ignore emissions because the take(0) approach would have more overhead (every emission from source would prompt the emission of a new GroupedObservable) than the ignoreElements approach.

By the way, ignoreElements has a drawback: It keeps all group Observables in memory even some of them won't emit items.

akarnokd added a commit that referenced this pull request Jan 11, 2016
clarify behaviour of groupBy in javadoc
@akarnokd akarnokd merged commit b087eff into ReactiveX:1.x Jan 11, 2016
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.

3 participants