File tree Expand file tree Collapse file tree
Examples/SingleNavigator/02-SingleEventSubscriber/SingleEventSubscriber/Page/Page2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import LinkNavigator
22import Combine
33
44class Page2LinkSubscriber : ObservableObject {
5- private ( set ) var linkAction : PassthroughSubject < Page2LinkSubscriber . Action , Never > = . init ( )
5+ @ Published var linkAction : Page3View . Page2InjectionData ? = . none
66
77 deinit {
88 print ( " Page2LinkSubscriber deinit... " )
@@ -12,14 +12,7 @@ class Page2LinkSubscriber: ObservableObject {
1212extension Page2LinkSubscriber : LinkNavigatorItemSubscriberProtocol {
1313 func receive( encodedItemString: String ) {
1414 if let scope: Page3View . Page2InjectionData ? = encodedItemString. decoded ( ) {
15- guard let scope else { return }
16- linkAction. send ( . page2ToData( scope) )
15+ linkAction = scope
1716 }
1817 }
1918}
20-
21- extension Page2LinkSubscriber {
22- enum Action {
23- case page2ToData( Page3View . Page2InjectionData )
24- }
25- }
Original file line number Diff line number Diff line change @@ -14,8 +14,6 @@ struct Page2View: View {
1414 self . linkSubscriber = linkSubscriber
1515 }
1616
17- @State var message : String = " "
18-
1917 var body : some View {
2018 ScrollView {
2119 VStack ( spacing: 40 ) {
@@ -39,20 +37,13 @@ struct Page2View: View {
3937 . font ( . footnote)
4038 . foregroundColor ( . secondary)
4139
42- Text ( message)
40+ Text ( linkSubscriber . linkAction ? . message ?? " - " )
4341 }
4442 }
4543
4644 Spacer ( )
4745 }
4846 . padding ( )
4947 }
50- . onReceive ( linkSubscriber. linkAction) { action in
51- switch action {
52- case . page2ToData( let eventData) :
53- message = eventData. message
54- return
55- }
56- }
5748 }
5849}
You can’t perform that action at this time.
0 commit comments