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

More efficient collect by time/scheduler? #127

Open
jessegrosjean opened this issue May 22, 2022 · 0 comments
Open

More efficient collect by time/scheduler? #127

jessegrosjean opened this issue May 22, 2022 · 0 comments

Comments

@jessegrosjean
Copy link

Thanks for CombineExt, I've been using in my apps for a long time.

I recently ran into a performance issue with "Combine" .collect(.byTime). It starts a repeating timer that runs for the entire duration of the subscription. Depending on the time stride and how many of these you have it can really effect performance even when no items are getting published.

The problem that I was trying to solve with .collect(.byTime) is:

  1. You have background work being performed and generating a sequence of results.
  2. You have a UI that you want to update with those results (you want them all, not just last/first)
  3. You want to batch process the results, it's too expensive to schedule each result separately on the main queue.
  4. You only want to schedule a timer when items are passing through the publisher, don't want a repeating timer

If there's a good Combine or CombineExt way to do this I would love to know. Otherwise I have a publisher that does what I need here. The timing logic is quite simple, though I don't really understand the details of the surrounding "Combine" logic. It's mostly copied/pasted from CombineX.

https://forums.swift.org/t/combines-collect-bytime-schedules-a-repeating-timer/57456

Assuming this type of scheduler doesn't already existing I think the basic logic would be a good addition to CombineExt, though probably someone more in tune with combine internals should check and adapt the code to CombineExt.

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