-
Notifications
You must be signed in to change notification settings - Fork 0
/
BindingTestView.swift
45 lines (39 loc) · 1001 Bytes
/
BindingTestView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// BindingTestView.swift
// Tinker2
//
// Created by Helge Heß on 21.06.19.
// Copyright © 2019 Helge Heß. All rights reserved.
//
#if false // duplicate ObservableObject
#if canImport(Combine)
import Combine
#elseif canImport(OpenCombine)
import OpenCombine
#endif
#else
#if canImport(Combine)
import class Combine.PassthroughSubject
#elseif canImport(OpenCombine)
import class OpenCombine.PassthroughSubject
#endif
#endif
import SwiftWebUI
class BindingTestStore: ObservableObject { // FIXME
static let global = BindingTestStore()
var didChange = PassthroughSubject<Void, Never>()
var i = 5 { didSet { didChange.send(()) } }
func advance() {
i += 1
}
}
struct BindingTestView: View {
@ObservedObject var store = BindingTestStore.global
var body: some View {
VStack(alignment: .leading) {
Text("Hello \(store.i)")
//BindingObjectBindingButton(store: store)
Button("Advance") { self.store.advance() }
}
}
}