SwiftUI and Redux — Clean Code and Small, Independent Components

How to use the Redux library and integrate it in your SwiftUI app

Thomas Ricouard
Better Programming
Published in
6 min readJul 26, 2019
Photo by Crew on Unsplash

Redux is really cool, SwiftUI is even cooler, and having both in the same app is heaven on earth. So, yet again, I’ll try to convince you that this is the best (or worst) SwiftUI app architecture.

During the past few weeks, I’ve evolved my small, naive Redux SwiftUI library. I’ve added a readme which barely explains how to make it work in your app, but I have a working example anyway.

More importantly, I’ve added StoreProvider, StoreConnector, and ConnectedView.

I can’t thank Alexey Demedeckiy enough, as the new additions are heavily inspired by his earlier work on SwiftUI and Redux. I’ve added it to my library and refactored part of MovieSwiftUI with it. It works wonders with my pre-existing Redux architecture.

I won’t talk about Redux concepts in this article, this is a tutorial on how to use the library and integrate it into your SwiftUI app.

It’ll, of course, give you an overview of how it all works together but it’s more about components architecture. For explanations, you can refer to my previous article linked in the first paragraph.

That said, let’s dig into the code.

Any SwiftUI project will have a SceneDelegate — this is a new class since iOS 13/macOS 10.15, which manages the windows instances and presentation of your app.

This is basically the new entry point and where you’ll initialize your root-view hierarchy.

In our case, we’ll also create our Redux initial state and provide it to our store, then wrap it using StoreProvider around our root view.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Thomas Ricouard
Thomas Ricouard

Written by Thomas Ricouard

📱 🚀 🇫🇷 [Entrepreneur, iOS/Mac & Web dev] | Now @Medium, @Glose 📖| Past @google 🔍 | Co-founded few companies before, a movies 🎥 app and smart browser one.

No responses yet

Write a response