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

New Subscribers helper method? #3057

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

New Subscribers helper method? #3057

davidmoten opened this issue Jul 1, 2015 · 3 comments

Comments

@davidmoten
Copy link
Collaborator

This sort of code is in a lot of places in the RxJava codebase:

    new Subscriber<T>(s) {
            @Override
            public void onNext(T t) {
                s.onNext(t);
            }
            @Override
            public void onError(Throwable e) {
                s.onError(e);
            }
            @Override
            public void onCompleted() {
                s.onCompleted();
            }
        }

I'd like to add a utility method in Subscribers that does this. Any suggestions for a name to squeeze into the static namespace of this class? from would have been nice but is used by Subscribers.from(Observer) and this would be a breaking change if I added Subscribers.from(Subscriber) because they do different things and a Subscriber is an Observer.

Perhaps:

  • Subscribers.fromChained(Subscriber)
  • Subscribers.passThrough(Subscriber)
  • Subscribers.chained(Subscriber)

I'm sure someone will have a nicer suggestion than these.

@wujek-srujek
Copy link

Subscribers.wrap(s)?

@davidmoten
Copy link
Collaborator Author

I like wrap, thanks @wujek-srujek

@davidmoten
Copy link
Collaborator Author

This has been merged

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

3 participants