Combine Schedulers: Controlling Time

Episode #105 • Jun 8, 2020 • Subscriber-Only

The Scheduler protocol of Combine is a powerful abstraction that unifies many ways of executing asynchronous work, and it can even control the flow of time through our code. Unfortunately Combine doesn’t give us this ability out of the box, so let’s build it from scratch.

Controlling Time
Introduction
00:05
The Scheduler protocol
00:48
Testing immediate scheduling
13:16
Testing delayed scheduling
27:47
Testing timers
35:31
Timer cancellation
43:33
Timer complexity
47:49
Timer scheduling
53:40
Next time: erasing time
65:31

Unlock This Episode

Our Free plan includes 1 subscriber-only episode of your choice, plus weekly updates from our newsletter.

Introduction

This just doesn’t seem to be very dependable. I wouldn’t want to depend on this test suite where first there’s magical constants being used to determine how long to wait, and second the test suite could randomly fail for no fault of our own. This creates an environment of not trusting our test suite.

Luckily Combine gives us a tool for handling this. The crux of the problem is that we used DispatchQueue.main when telling our publishers what queue to receive values on and when describing how to debounce values.

This episode is for subscribers only.

Subscribe to Point-Free

Access this episode, plus all past and future episodes when you become a subscriber.

See plans and pricing

Already a subscriber? Log in

References

combine-schedulers

Brandon Williams & Stephen Celis • Sunday Jun 14, 2020

An open source library that provides schedulers for making Combine more testable and more versatile.

Downloads