Last updated 1 min read

Puredux Multithreading

Related: Puredux, Software Engineering, iOS App Development


As a framework, Puredux fits you in certain limitations.

Dealing with multithreading is just like dealing with an app architecture: if you don't apply certain restrictions for consistency reasons, it becomes a mess.

Swift concurrency brings a lot of structure to how multithreaded code looks and works, but it doesn't save from 2 important things: mess and race conditions.

Building with Puredux is just another dimension of structured concurrency. Puredux is restictive. It takes responsibility for multithreading and ensures that work related to certain app layers is performed on the right thread.

Puredux stores operate asynchronously on a global queue with a configurable priority. It means that the whole app logic is performed in the background because it's all performed in the store's reducers, leaving the main thread for only one thing: UI.

Why?

The sad truth: 60 fps UI allows only a 0.016-sec timespan for a roundtrip between user interaction and the result in the interface. Most of that time will be spent on the layout and rendering on the main thread. We don't have a lot of time there.

That means that every tiny computation we put on the main thread robs a bit of your app's responsiveness and moves things toward UI freeze.

Puredux ensures that the main thread is not polluted.