Skip to content

Commit

Permalink
Add bindings section to ObservationBackport.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrandonw authored Feb 26, 2024
1 parent 468d205 commit b832aa4
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,29 @@ To debug this, expand the warning in the Issue Navigator of Xcode (⌘5), and cl
frames displayed to find the line in your view where you are accessing state without being inside
`WithPerceptionTracking`.

## Bindings

If you want to derive bindings from the store (see <doc:Bindings> for more information), then you
would typically use the `@Bindable` property wrapper that comes with SwiftUI:

```swift
struct MyView: View {
@Bindable var store: StoreOf<MyFeature>
// ...
}
```

However, `@Bindable` is iOS 17+. So, the Perception library comes with a tool that can be used in
its place until you can target iOS 17 and later. You just have to qualify `@Bindable` with the
`Perception` namespace:

```swift
struct MyView: View {
@Perception.Bindable var store: StoreOf<MyFeature>
// ...
}
```

## Gotchas

There are a few gotchas to be aware of when using `WithPerceptionTracking`.
Expand Down

0 comments on commit b832aa4

Please sign in to comment.