View does not update when migrate to observation #2619
Jimmy-Prime
started this conversation in
Beta
Replies: 1 comment 2 replies
-
Hi @Jimmy-Prime, this does not work because you are creating and discarding all new var toggle: DetailFeature.State {
get {
.init(detail: item.detail)
}
set {
item.detail = newValue.detail
}
} That means the observation registrar in that state is getting reset every time, and hence observation is not working. But we do not recommend structuring features like this in general. It is far better to keep things simple and hold onto child state directly in parent state: @ObservableState
struct State: Equatable {
var toggle: DetailFeature.State
init(item: Item) {
self.toggle = DetailFeature.State(detail: item.detail)
}
} That works just fine with observation. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I find view is not updating when trying to migrate features that have this shape.
An
ItemFeature
that operates onItem
and anDetailFeature
that operates onItem.Detail
DetailFeature
works fine standalone, but when it's embedded inItemFeature
, view is not updating. If I roll both features back before observation, everything works fineI am on revision
67e9c64f5e62db4d66b359eeb66e0f3d6c564b89
Beta Was this translation helpful? Give feedback.
All reactions