File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Samples/TicTacToe/Sources/Authentication Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -45,10 +45,10 @@ struct LoginScreen: SwiftUIScreen {
4545 get: \. password,
4646 set: Action . passwordUpdated
4747 ) ,
48- onCommit: { model. value . actionSink . send ( . login) }
48+ onCommit: model. action ( . login)
4949 )
5050
51- Button ( " Login " , action: { model. value . actionSink . send ( . login) } )
51+ Button ( " Login " , action: model. action ( . login) )
5252 }
5353 . frame ( maxWidth: 400 )
5454 }
Original file line number Diff line number Diff line change @@ -104,3 +104,14 @@ public final class ObservableValue<Value>: ObservableObject {
104104 return subject. removeDuplicates ( by: isDuplicate) . eraseToAnyPublisher ( )
105105 }
106106}
107+
108+ #if canImport(UIKit)
109+
110+ public extension ObservableValue where Value: SwiftUIScreen {
111+ func action( _ action: Value . Action ) -> ( ) -> Void {
112+ // TODO: Should this closure capture the current `actionSink` instead?
113+ { [ weak self] in self ? . value. actionSink. send ( action) }
114+ }
115+ }
116+
117+ #endif
You can’t perform that action at this time.
0 commit comments