Skip to content

Instantly share code, notes, and snippets.

@chriseidhof
Last active July 9, 2019 09:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriseidhof/2e20006ed80cf7cb3e6fb303c023ee61 to your computer and use it in GitHub Desktop.
Save chriseidhof/2e20006ed80cf7cb3e6fb303c023ee61 to your computer and use it in GitHub Desktop.
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