🎉 End-of-year Sale! Save 25% when you subscribe today.

Composable Navigation: Alerts & Dialogs

Episode #223 • Feb 20, 2023 • Subscriber-Only

Let’s dip our toes into the new composable navigation tools by improving how alerts and confirmation dialogs can used in the library. We will create a new reducer operator that more correctly handles the logic and hides unnecessary details.

Previous episode
Composable Navigation: Alerts & Dialogs
Next episode
Locked

Unlock This Episode

Our Free plan includes 1 subscriber-only episode of your choice, plus weekly updates from our newsletter.

Sign in with GitHub

Introduction

Brandon

So, we are seeing that if you want integrated features in vanilla SwiftUI in order to reap all the benefits that brings, you still have a number of steps to take to get it right, but in some sense there is even less help from the compiler and runtime to make sure you did everything correctly.

We think everything we have accomplished so far is pretty cool and even impressive, but its real purpose is to dip our toes into composing features together and communicating between features, because that concept is central to the Composable Architecture, and even more so with navigation.

By composing many features together, including all the destinations one can navigate to, we can have a very simple representation of something that is actually quite complex. No matter how many different places you can navigate to from a screen, and no matter how many layers deep you are in a navigation stack, you will have the ability to inspect what is happening in every layer and introduce new logic to integrate everything together. It’s honestly amazing to see.

Stephen

But building those tools takes time, and to get the first hint at what those tools will look like eventually we will turn to one of the simplest forms of navigation: alerts. Alerts have the notion of presenting and dismissing, but they don’t manage logic and behavior on the inside. They simply show some buttons, and the user taps one of them to dismiss and optionally kick off an action.

Let’s start by showing how we can add an alert to this application using the tools that the Composable Architecture already comes with, and in fact these tools have been in the library since basically the beginning. And then we will see how we can greatly improve the tools, and that will set the stage for more complicated forms of navigation, such as sheets, popovers ,and even drill-downs.

Alerts today


References

Downloads

Get started with our free plan

Our free plan includes 1 subscriber-only episode of your choice, access to 64 free episodes with transcripts and code samples, and weekly updates from our newsletter.

View plans and pricing