Monday, May 23, 2022

Combine’s .collect(.byTime) Timer

Jesse Grosjean:

The biggest bug in Bike’s 1.0 release was excessive CPU use while in background.

[…]

First, I didn’t realize that each time you use .collect(.byTime) you are setting up a new repeating timer. I had expected a timer was involved, but thought it would only get scheduled when new items were coming into the publisher. Nope, it’s repeating once the pipeline is setup.

[…]

I’ve posted a .collect(.byTime) replacement (for my use case) here. It solves the problem by only scheduling on the runloop once per group of incoming results.

Previously:

1 Comment RSS · Twitter

Mayson Lancaster

Bike 1.0.1 was just released.

Leave a Comment