Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SwiftUI Problem - FB6571851
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
You can’t perform that action at this time.