State containment grids, and don’t cross the streams.
August 24, 2021 5:00 PM 5:40 PM Aspen Ballroom
Outside our apps the world is a messy place. Servers return errors, bluetooth devices come in and out of range. Even iOS conspires against us, unceremoniously dumping us into the background or foreground when we least expect it.
This mess mutates state in unwelcome places like a big Twinkie – from the bottom of the stack even up into our view controllers if we aren’t careful.
But being constantly careful and writing fault tolerant code is exhausting and error-prone.
We need a systematic way to encapsulate this state, a high voltage laser containment system if you will, to keep mutating state in one place where errors can be handled, ambiguities can be resolved, and everything can be thoroughly unit tested.
And we want patterns to make sure that the rest of our code stays as stateless as possible.
In this talk I will show how to use the Actor model and Finite State Machines to encapsulate state in a performant thread-safe way.
We will then join these models with Combine and the Swift Type System to help keep our code as stateless as possible.