Did you know Swift actors can share the same isolation and communicate with one another in a completely synchronous manner?
This week we apply the idea to ComposableArchitecture 2.0, where a scoped StoreActor can wrap a parent and share parts of the same core domain and state.
This week we conclude our series by showing how to share isolation across boundaries!
By abstracting our nonisolated core with a protocol, isolated shells can scope down to subfeatures while retaining all the benefits of controlled isolation.
https://t.co/7QjjpC1yaf
This week we started reaping the benefits of "nonisolated core, isolated shell". We write features a single time, without thinking about isolation, then wrap the feature in the isolation we need. @MainActor for SwiftUI, arbitrary actor for tests!
https://t.co/8G8ZDpxed5
Advanced Swift macro technique: Accessing inferred types
Macros only see the syntax of Swift code, so it seems impossible to access inferred types. But with a clever trick involving associated type inference, we can achieve the seemingly impossible!
https://t.co/Io2k8Mvisg
Part 1 of our Advanced Swift Macros series is out!
You may think macros can only see the stringy syntax of Swift code, but it is possible to tease out some static type information. You can even detect if a type conforms to a protocol!
🤯 https://t.co/1PVTKOkXQn
Come for the real world explanations of isolation in Swift, stay for the deep dives into esoteric underscored attributes like '@_inheritActorContext(always)' 🤣
https://t.co/eP6BQ78pz4
This week we explore the “Nonisolated Core, Isolated Shell” pattern in Swift using a type that drives the business logic of a SwiftUI app.
A nonisolated “Core” type is hosted in an isolated “Store” type, simplifying the complexities one typically encounters in Swift concurrency.
“Nonisolated Core, Isolated Shell” is our mantra for wielding Swift concurrency effectively, with minimal suspension points and locking, and maximal reliability and testability.
Modern concurrency tools like nonisolated(nonsending) and Task.immediate got us closer to our goal, but not all the way. So we’re trying a new approach inspired by Gary Bernhardt’s “functional core, imperative shell”:
Nonisolated core, isolated shell.
https://t.co/SP35LNtGzu
Modern concurrency tools like nonisolated(nonsending) and Task.immediate got us closer to our goal, but not all the way. So we’re trying a new approach inspired by Gary Bernhardt’s “functional core, imperative shell”:
Nonisolated core, isolated shell.
https://t.co/SP35LNtGzu
If you’re interested in writing async code that is easy and reliable to test, and free of UI glitches from thread hops, nonisolated(nonsending) and Task.immediate can get you there!
We tried using two modern Swift concurrency tools to allow us to embrace non-sendability:
• nonisolated(nonsending)
• Task.immediate
They got us close to our goals, but sadly there were still data races. Watch this week's episode to understand why:
https://t.co/szqZAGtrfb
We tried using two modern Swift concurrency tools to allow us to embrace non-sendability:
• nonisolated(nonsending)
• Task.immediate
They got us close to our goals, but sadly there were still data races. Watch this week's episode to understand why:
https://t.co/szqZAGtrfb
Our deep dive into Swift isolation from a few months back may have been a bit abstract for people, so we are bringing things down to earth by designing real world code with isolation in mind from the beginning:
https://t.co/GUP26Q72lA
Our code is at an impasse: we want to embrace non-sendability, but async work seems to force us into Sendable. We’ll revisit our approach to this problem from ComposableArchitecture 1.0, see why it's not ideal, and search for a better way.
https://t.co/szqZAGtrfb
It’s time to put what we’ve learned about isolation into practice. We’re building the reimagined Composable Architecture 'Store' from scratch and exploring the benefits of strictly controlling isolation through every layer of the library.
https://t.co/pOQfGG8oxy
Earlier this week we held our first Point-Free Office Hour. We answered questions from our viewers and gave a tiny preview of a new library we are working on.
Check it out:
https://t.co/OxJU5sjb2P
@auramagi@pointfreeco To each their own! If a team finds View.init to be more of a footgun than the optional landmine, they’re free to take a different approach :) Each approach has its pros and cons, but we prefer the trade-offs afforded by LazyState.