Skip to content
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

Adjust for ObservableObject being in Combine, and willChange instead of didChange #47

Open
helje5 opened this issue Oct 18, 2019 · 8 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@helje5
Copy link
Member

helje5 commented Oct 18, 2019

This might require a little rework.

Combine also has the @Published, though SwiftUI still has the @ObservedObject.

@helje5 helje5 added bug Something isn't working help wanted Extra attention is needed labels Oct 18, 2019
@shial4
Copy link
Contributor

shial4 commented Jan 9, 2020

I don't think @ObservedObject in this project is working. Is it?
If it should. I had no luck with getting it to compile while having @ObservedObject wrapper somewhere. :/

@helje5
Copy link
Member Author

helje5 commented Jan 9, 2020

It should work, here is the sample I was testing with: https://github.com/SwiftWebUI/Tinker2/blob/master/Sources/Tinker2/Views/Tests/BindingTestView.swift

@shial4
Copy link
Contributor

shial4 commented Jan 9, 2020

What is this for?
#if canImport(Combine)
import Combine
#elseif canImport(OpenCombine)
import OpenCombine
#endif

Should I add OpenCombine to the project? I think it is not working due to the fact the Two types ObservableObject are colliding with each others.

@shial4
Copy link
Contributor

shial4 commented Jan 9, 2020

I've copy example from here example

That's what I am getting.

Screen Shot 2020-01-10 at 8 52 52 am

Without SwiftWebUI.Obse.... I have error such as:

'ObservableObject' is ambiguous for type lookup in this context

@helje5
Copy link
Member Author

helje5 commented Jan 9, 2020

All this is completely unrelated to this issue. OpenCombine is required on Linux, on macOS you can use the regular Combine (but you need Catalina).

@shial4
Copy link
Contributor

shial4 commented Jan 9, 2020

What I meant is that I still can't get it to work. Due to errors presented above.

@helje5
Copy link
Member Author

helje5 commented Jan 9, 2020

Oh, sorry. Actually it may not work indeed 🤔 That's what the issue is about 😄
I suppose SwiftWebUI is still assuming didChange, but ObservedObject already switched to willChange. Things probably go wrong ...

This might require a little rework.

I'm not sure how much, maybe it isn't actually that bad. Just replacing didChange w/ willChange might work, because WebUI is still working in a transaction. The "will" will still mark the view as dirty and should trigger the diffing.

@shial4
Copy link
Contributor

shial4 commented Jan 10, 2020

Resolved compiling issue. By placing ObservableObject in separate file with one import of SwiftWebUI.
Now I can work it out what's happening inside. See if and what is required to be corrected

shial4 pushed a commit to shial4/SwiftWebUI that referenced this issue Jan 10, 2020
shial4 pushed a commit to shial4/SwiftWebUI that referenced this issue Jan 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants