Skip to content

Changes on @ObservableObject inside State does not update UI #1630

Answered by tgrapperon
raduncicen asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @raduncicen!
If you're using UIViewRepresentable, its Coordinator is not required to be an ObservableObject, and it will furthermore not be observed as such by the Representable. When using UIViewRepresentable, the Coordinator is private, and usually an implementation detail with which you don't talk directly (for example from a reducer).
I never tried to install the Coordinator as an ObservedObject directly in the UIViewRepresentable, so I don't know if it would work.
So the idea is to wrap UIKit in UIViewRepresentable, ideally with a value-type API and closures/bindings to control it. But in your case, it could maybe work if you simply rewrite your View's init like this:

let store: S…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@saroar
Comment options

Answer selected by raduncicen
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
4 participants
Converted from issue

This discussion was converted from issue #1629 on November 05, 2022 14:13.