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

Combine Publisher needs back pressure management #42

Closed
gahntpo opened this issue Apr 6, 2021 · 4 comments
Closed

Combine Publisher needs back pressure management #42

gahntpo opened this issue Apr 6, 2021 · 4 comments

Comments

@gahntpo
Copy link

gahntpo commented Apr 6, 2021

Issue created in response to #27

According to Apple Combine Subscriptions have to fulfill the contract between publishers and subscribers with backpressure management. This is discussed in the WWDC presentation https://developer.apple.com/videos/play/wwdc2019/722/
The UIControl Event publisher is missing handling of the subscriber's demand. This is so far simply ignored.

I would like to add the demand management

@freak4pc
Copy link
Member

freak4pc commented Apr 6, 2021

I'm not opposed to simply pulling DemandBuffer from CombineExt into the project to deal with back pressure but I have to say that limiting demand for UI events is a highly unlikely use case. Do you have such a practical use case or are you more interested in the technical completeness ?

Thanks

@gahntpo
Copy link
Author

gahntpo commented Apr 6, 2021

If I have a subscriber with a request that is not unlimited, it is simply ignored. The use case would be starting fetches
flatmap(maxPublisher: .max(2) ) { url in URLSession.default.dataTaskPublisher(for url:) }
the maxPublisher allows me to decide how many network requests I want to do concurrently. once the flatmap is finished with one network request, it will send a new demand to its publisher. and receive the new value. This helps me to do batch requests with flatmap. I can also set max(1) to do my network requests in serial. But for this to work properly the upstream publisher needs to fulfill the demand handling.

@freak4pc
Copy link
Member

freak4pc commented Apr 6, 2021

Thanks, I think you misunderstood what I'm asking.
I'm asking what is the use case for back pressuring UI events (like ControlEvent/ControlTarget publishers) ?

flatMap itself still respects back pressure so using the format you mentioned here shouldn't be affected by CombineCocoa to the best of my understanding.

@freak4pc
Copy link
Member

Closing for now. If you have additional details / context on this please let me know and I can reopen. Thank you! :)

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

2 participants