Observation: The Gotchas

Episode #254 • Oct 23, 2023 • Subscriber-Only

While the @Observable macro improves upon nearly every aspect of the @State and @ObservedObject property wrappers, it is not without its pitfalls. We will explore several gotchas that you should be aware of when adopting observation in your applications.

Previous episode
The Gotchas
Introduction
00:05
Gotcha: withObservationTracking
00:51
Gotcha: Value types
06:53
Gotcha: Reference types
21:58
Gotcha: Value/reference equatability/hashability
22:20
Gotcha: Testing
26:58
Gotcha: Spooky action at a distance
35:50
Gotcha: A new era of reference types
40:15
Next time: The future
47:13

Unlock This Episode

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

Introduction

Brandon: And theoretically it would even be possible to backport all of this code to work on iOS 16 and earlier. However, you wouldn’t be able to backport the SwiftUI support. That unfortunately requires iOS 17.

Stephen: OK, we have no gone deep into the new Observation framework. We understand the problems it’s trying to solve, and see concretely just how magical it can be to use it. But we’ve also explored its primary observation tracking tool, and even dug into the actual source code to see how it the tool roughly works.

The tool is pretty incredible to use, and solves so many pain points of the original tools, but it does have some gotchas and problems of its own. It is very important to understand these downsides otherwise you can easily find yourself in a situation where you are accidentally observing far too much state.

Let’s dig in.

This episode is for subscribers only.

Subscribe to Point-Free

Access this episode, plus all past and future episodes when you become a subscriber.

See plans and pricing

Already a subscriber? Log in

Downloads