Closed samskinner32 closed 1 year ago
Some of that is covered in the documentation on InjectedObject
But the problem with ObservableObject and protocols is that there are associated type issues, which I wrote about here.
The real solution is not to mix view models and protocols.
Hello! I am fairly new to Swift/SwiftUI/Factory, so this may be a non-sensical or bad question, forgive me!
I am using Factory (v1.2.8) to inject various services into the app, some of which are singletons that hold data that I want to access on different screens. E.g. I have a
FriendService
that holds an array of[Friend]
and also has functions to fetch and update this array. What I WANT to happen is that if I'm on a View and this array updates, I'd like the View to re-render. Right now, I'm having to manually trigger a re-render for the View's data to show the latest service data. (Hopefully that makes sense so far...)Very simplified relevant code here:
My Service:
My Container:
My View:
--
In my ideal world, I'd want it to be like...
so that my View reacts to changes when
friends
updates.Is that possible? Let me know if this needs more context or makes no sense. Really appreciate any responses. Thank you! :)