🎉 Black Friday Sale! Save 30% when you subscribe today.

Async Composable Architecture: Streams

Episode #198 • Jul 25, 2022 • Subscriber-Only

We introduce another helper to the Effect type that can use an asynchronous context to send multiple actions back into the system. By leveraging Swift’s structured concurrency we can create complex effects in a natural way, all without sacrificing testability.

Previous episode
Async Composable Architecture: Streams
Next episode
Locked

Unlock This Episode

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

Sign in with GitHub

Introduction

So things are starting to look pretty good. Not only can we use Effect.task to open up an asynchronous context for our effects, which allows us to perform as many awaits as we want and use a familiar coding style to compute the data that we want to feed back into the system, but we can now also leverage async sleeping in order to introduce delays into our effects.

And best of all, it’s still all testable. Sure we had to insert a little bit of hackiness into our test scheduler, but hopefully Swift will someday introduce tools that allow us to have more control over how work is scheduled in the concurrency runtime.

But there is still a pretty big blind spot in our asynchronous effects story for the Composable Architecture. And that’s effects that need to send multiple actions back into the system. Effect.task works great for when we have a single action, but what if we need to send many?

It’s totally possible to support this, and in doing so we will be able to greatly simplify many complex effects, and further reduce our reliance on Combine.

Timer counter


References

  • Collection: Concurrency
    Brandon Williams & Stephen Celis
    Note

    Swift has many tools for concurrency, including threads, operation queues, dispatch queues, Combine and now first class tools built directly into the language. We start from the beginning to understand what the past tools excelled at and where they faultered in order to see why the new tools are so incredible.

Downloads

Get started with our free plan

Our free plan includes 1 subscriber-only episode of your choice, access to 64 free episodes with transcripts and code samples, and weekly updates from our newsletter.

View plans and pricing