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

toBlocking ignore all #3063

Closed
davidmoten opened this issue Jul 3, 2015 · 5 comments
Closed

toBlocking ignore all #3063

davidmoten opened this issue Jul 3, 2015 · 5 comments

Comments

@davidmoten
Copy link
Collaborator

When I want to use toBlocking and I want to ignore results but wait for completion I will often do

observable.count().toBlocking().single();

This works but I'd like something concise for this common use case. We have a forEach method that takes an Action1. What about a forEach overload that takes no argument?

observable.toBlocking().forEach();

or perhaps .ignoreElements()?

@akarnokd
Copy link
Member

akarnokd commented Jul 3, 2015

I've been thinking about this too and could use these new blocking methods:

  • run() or subscribe() run to completion or exception
  • subscribe(Observer), subscribe(Action1, Action1) and subscribe(Action1, Action1, Action0) blocking callback style
  • subscribe(Subscriber) allow breaking out of the iteration and have the unsubscription properly propagate up.

@davidmoten
Copy link
Collaborator Author

Sounds good, may as well duplicate all the subscribe() overloads across to BlockingObservable that make sense. That symmetry would be nice.

@pkafel
Copy link

pkafel commented Jul 29, 2015

+1 for the topic. I have many use cases where I would love to use something like that !

@tommack
Copy link

tommack commented Aug 11, 2015

I'll throw none() out there. Would be a void method that threw an Exception if any elements were output.

observable.ignoreElements().toBlocking().none();

@akarnokd
Copy link
Member

See for the proposed methods in #3174.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants