promotion
Powerful debugging in Xcode,
no code changes or 3rd party frameworks required.

Swift Async Sequence extensions (part 2)

In Swift Async Sequence extensions (part 1) I covered simple ways to create an async sequence using a custom factory method and binding a sequence to a UI control via a custom assign method. This covered the “beginning” and “end” of the data stream (so to say) but what about processing or converting the data along the way? If you draw a parallel to Combine code — how would you build custom “operators” for your async sequence? …

Posted on

Swift Async Sequence extensions (part 1)

I’ve been trying out various ways to extend and build upon the currently available Concurrency APIs introduced in Swift 5.5 I believe the Concurrency APIs are intentionally somewhat minimal so that developers would intentionally fall back on Combine for complex tasks. Maybe I’m right or wrong but I can see how a lot of people will want to extend the Concurrency APIs to suit better their current tasks. In this post I’ll code a couple of extensions that show how to easily build your own concurrent power-ups. …

Posted on

Bridge from Combine to AsyncSequence - the code (p. 2)

Yesterday I wrote about AsyncSequence, AsyncStream and a simple plan how to bridge (or proxy) Combine publishers to the new asynchronous sequences APIs - Bridge from Combine to AsyncSequence - the plan (part 1). Today let’s put together the code as planned and see if that’s going to work out so we can easily use publishers as async sequences. CombineAsyncStream setup I’ll create a new type called CombineAsyncStream and make it conform to AsyncSequence. …

Posted on

Bridge from Combine to AsyncSequence - the plan (p. 1)

Previously, I wrote about actors in Actors part 1 and Actors part 2; this time I’m going to cover how to write a Combine operator to proxy a Combine publisher into an async sequence that you can iterate over by using a simple for loop. Note: The current version of Xcode 13 is beta 2 and I’m going to be using the latest swift.org toolchain nightly snapshot in order to make use of AsyncStream. …

Posted on