Skip to content

New Subscribers helper method? #3057

Closed
Closed
@davidmoten

Description

@davidmoten

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions