-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Don't use @Published for ViewStore state #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
mbrandonw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sweet, thanks!
* Don't use @published for ViewStore state * Update ci.yml * Update format.yml
|
I just updated my TCA to How is the View suppose to update if |
All that I know this works since I had to do exactly the same thing in my ReactiveSwift version of the TCA. |
|
@DrewKiino sorry to hear about that. All of the demo apps in the repo seem to work just as they did before. And as @mluisbrown mentioned, we are just manually replicating what Is it possible to share some code that would help us reproduce the problem you are seeing? |
|
Thanks for the quick reply 👍🏼 I was able to figure it out, it turns out that Which you can fix by adding this into your let objectWillChange = ObservableObjectPublisher()Another article with the changes - So basically, |
|
Strange! I don't have Xcode 11.4 installed, but I do have Xcode 11.3 and all the case studies still seems to work, even without adding an |
|
@DrewKiino the posts you linked to are both referring to Xcode 11.0 betas from 2019, where this might have been a bug. However in the ReactiveSwift version of ViewStore I do explicitly create the |
|
I also just found this thread on the Swift Forums which seem to indicate that at least in November 2019, if you didn't have any This comment by @broadwaylamb really makes this clear:
I'm not sure when or if this behaviour changed, but IMO if you're not using any |
|
@mluisbrown it has changed in the recent versions of Combine. It now falls back to a global lookup table if there are no |
|
Thanks for the really fast reply @broadwaylamb 🙏 Do you know in which version of Combine this changed, and when the change was made? |
|
Unfortunately, no. |
Combine's beta includes a new
assign(to:)on publisher that can feed state updates to a@Publishedpublisher. We don't want this, so let's pingobjectWillChangedirectly.https://developer.apple.com/documentation/combine/publisher/assign(to:)