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

Should we remove Flowables::fromPublisher? #855

Open
lehecka opened this issue Jan 19, 2018 · 0 comments
Open

Should we remove Flowables::fromPublisher? #855

lehecka opened this issue Jan 19, 2018 · 0 comments

Comments

@lehecka
Copy link
Contributor

lehecka commented Jan 19, 2018

In the current api we have a method
Flowables::fromPublisher(OnSubscribe);
OnSubscribe = std::function<void(Subscriber)>;

In the body of the OnSubscribe lambda the user is required to call subscriber->onSubscribe(subscription) before calling any on{Next, Complete, Error}.

Problem:
In many cases the users are using this API to bridge from a standard callback api to flowables and they do it typically wrong.

Common user mistakes:

  • not calling onSubscribe first
  • the subscription passed into onSubscribe is receiving request(n) calls but the credits are often ignored.

The api is requiring the user to know the protocol intimately and not mess up credits. Its very bug prone.

Proposal
If we remove Flowables::fromPublisher, we will force the users to use Observables::create method which doesn't require onSubscribe to be called, nor it has flow control.

The fromPublisher method seems quite useful in the cases we are connecting a Subscriber instance to a different Flowable.

Maybe we can just rename fromPublisher to unsafeSubscriberGetter which would just discourage users to use it.

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

No branches or pull requests

1 participant