Last active
July 9, 2019 09:01
-
-
Save chriseidhof/2e20006ed80cf7cb3e6fb303c023ee61 to your computer and use it in GitHub Desktop.
SwiftUI Problem - FB6571851
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import Combine | |
final class Test: BindableObject { | |
let subject = PassthroughSubject<(), Never>() | |
private(set) var didChange: AnyPublisher<(), Never> = Publishers.Empty().eraseToAnyPublisher() | |
var value: String = "Hi" | |
init() { | |
print("Init") | |
didChange = subject.handleEvents(receiveSubscription: { [unowned self] sub in | |
print("Got subscription") | |
dump(self.subject) | |
}, receiveCancel: { | |
print("Got Cancel") | |
}).eraseToAnyPublisher() | |
} | |
deinit { | |
print("Got a deinit") | |
} | |
} | |
struct Dest: View { | |
@ObjectBinding var test = Test() | |
var body: some View { | |
Text("Hello \(test.value)") | |
} | |
} | |
struct ContentView : View { | |
var body: some View { | |
NavigationView { | |
List { | |
NavigationLink(destination: Dest(), label: { Text("Child") }) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment