Skip to content
Discussion options

You must be logged in to vote

The issue here is nested observable objects. Perception instruments the projection of a @Perception.Bindable object, but you are accessing a property on a nested object. The fix is to localize the @Perception.Bindable to that nested object before handing it off to SwiftUI:

+@Perception.Bindable var stateCache = viewModel.stateCache
 EditorView(
-    name: $viewModel.stateCache["foo", \.name],
-    value: $viewModel.stateCache["foo", \.value]
+    name: $stateCache["foo", \.name],
+    value: $stateCache["foo", \.value]
 )

Nesting objects and having this kind of access is subtle, so if you have ideas to improve the output of the warning message, please let us know!

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@stephencelis
Comment options

Answer selected by tonyarnold
@tonyarnold
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants