🎉 Black Friday Sale! Save 30% when you subscribe today.

Composable Navigation: Unification

Episode #226 • Mar 13, 2023 • Subscriber-Only

Let’s prepare to delete a lot of code. The navigation APIs we’ve built so far to drive alerts, dialogs, and sheets all have more or less the same shape. We can unify them all in a single package that can also be applied to popovers, fullscreen covers, and more!

Previous episode
Composable Navigation: Unification
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

Stephen

So this is all looking really incredible. We have substantially improved the sheet navigation tool we built previously by making sure that child effects are automatically torn down when the child feature goes away, and we provided a new tool that allows child features to dismiss themselves in a really lightweight way. It can be entirely encapsulated in the child feature. The parent doesn’t need to know about it at all.

And on top of that we dipped our toes into non-exhaustive testing. This tool is becoming more and more important because we keep making it easier to compose features together, and so there are going to be more times we want to write high level tests on how features interact with each other without needing to assert on literally everything happening in each feature.

Brandon

There are even more powerful features we could continue adding to these presentation APIs, and we will soon, but let’s also take a moment to remember how we got here. A few episodes back we first dipped our toes into the waters of new navigation APIs by creating some tools for alerts. And since then we have basically copied and pasted code a bunch of times, first for confirmation dialogs and then again for sheets.

Let’s finally start unifying these APIs because soon we will want to generalize them even further for popovers, fullscreen covers, and navigation links, and I don’t think we want to copy-and-paste code 3 more times.

Alert, dialog, sheet unification


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