Roddy :swift: on Nostr: npub1sy8vt…pw2zc Essentially a child View not updating when a property from its ...
npub1sy8vt0hed8vr58ueqjlvmpzylv9he2fvv04luf4z5vyzsuut5zvqfpw2zc (npub1sy8…w2zc) Essentially a child View not updating when a property from its parent changes.
We're following a strict MVVM approach (where each View has its own StateObject, that is initialised in the View's init with its dependent arguments). Of course, if those arguments change, the StateObject isn't recreated, so the View doesn't change
Solution was to also set those dependencies on the View, and add an .onChange modifier that will then call a ViewModel method to update the @Published property
Published at
2023-08-13 15:39:54Event JSON
{
"id": "8b4cab3d1cd7a2d47334191a396142b8f3b8587c9651a2bacdde43f1d49bb7f2",
"pubkey": "75ea293c0a83db2c59a217968193e45be8e9a391615e3add9ff08415ed4df2f5",
"created_at": 1691941194,
"kind": 1,
"tags": [
[
"p",
"810ec5bef969d83a1f9904becd8444fb0b7ca92c63ebfe26a2a30828738ba098",
"wss://relay.mostr.pub"
],
[
"p",
"36fb9c68c8ef310b82bc748f1a33086f5a42fcb02e6a0e59867fd3efb3298121",
"wss://relay.mostr.pub"
],
[
"e",
"340f3a16dbb28f88139baae0a3562b1e93727914a9fac10882df5c8466a22adc",
"wss://relay.mostr.pub",
"reply"
],
[
"proxy",
"https://iosdev.space/users/podomunro/statuses/110883058101335411",
"activitypub"
]
],
"content": "nostr:npub1sy8vt0hed8vr58ueqjlvmpzylv9he2fvv04luf4z5vyzsuut5zvqfpw2zc Essentially a child View not updating when a property from its parent changes.\n\nWe're following a strict MVVM approach (where each View has its own StateObject, that is initialised in the View's init with its dependent arguments). Of course, if those arguments change, the StateObject isn't recreated, so the View doesn't change\n\nSolution was to also set those dependencies on the View, and add an .onChange modifier that will then call a ViewModel method to update the @Published property",
"sig": "f602b89e0bd12d308c80ca4576bac4e43174b3442eed0e8669d32602ef454791ace93d8d96864e9b294f19c319a42f2ab45998d1d78166d294bb43bc4fe7f360"
}