Introducing Swift Async Algorithms

Announced today on the Swift.org blog:

As part of Swift’s move toward safe, simple, and performant asynchronous programming, we are pleased to introduce a new package of algorithms for AsyncSequence . It is called Swift Async Algorithms and it is available now on GitHub.

Please check out the blog post for details, or go right to the repository!

Questions on the blog post can be asked here!

CC @Tony_Parker

61 Likes

Is this a partial replacement for the Combine framework? It appears like there are a lot of similar operations.

We learned a lot from our work on Combine, and this project takes that work and applies it. There are obviously a few key areas that this package does not touch on (e.g. @Published or ObservableObject since those interact more so with SwiftUI than anything else), but there are a ton of similarities there because they are similarly useful concepts. This package takes that work and now integrates the language fundamentals like async/await and Task.

16 Likes

Looks like a great start and an exciting project, thank you!

Where is the appropriate place to share ideas and suggestions for new features?

We've got our own section on the forums over here: Swift Async Algorithms - Swift Forums. As mentioned in the post, we're looking forward to discussing your ideas, feedback, and more.

2 Likes

Cool, I’ve already got a use case for the debounce operation :slight_smile:

Though I’m thinking, these operations are rather fundamental, shouldn’t this be part of the standard library? I don’t exactly enjoy adding the same package dependencies to all of my projects over and over.

2 Likes

Would it be possible to make it work in conjunction with @Published / ObservableObject / SwiftUI down the road? If so, would that need a library change or would it be a matter of providing some not too complicated intermediaries / wrappers in the app?

I don't find Combine particularly clean and straightforward to use, so would like to see other alternatives, but being swiftUI oriented developer - that's what I need the thing to work with to be able considering it.

1 Like

It is not something that is trivial that is for sure. That boundary is not really part of this project and more so something the folks working on SwiftUI are more equipped to tackle.

That being said there are some facilities like @State and the view modifier .task that can make async/await concepts like interacting with async sequences work; particularly AsyncChannel fits into this territory as an intermediary type.

This package is focused on the things below that layer; algorithms like zip(_:_:) or debounce(for:...) or types like AsyncChannel. Some of them can help aide in making that boundary better but I don't think it is really in the goals for the AsyncAlgorithms package to offer that UI/model interaction itself.

6 Likes

I'm so happy this was made as a Swift Package instead of being put in the Standard Library! That's going to make evolution so much easier. Excited to contribute in the future!

Also the validation feature using result builders and custom marble diagrams is amazing.

8 Likes