File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
Samples/TicTacToe/Sources/Authentication Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ struct LoginScreen: SwiftUIScreen {
32323333 text: model. binding (
3434 get: \. email,
35- set: { screen in { screen . actionSink . send ( . emailUpdated( $0 ) ) } }
35+ set: Action . emailUpdated
3636 )
3737 )
3838 . autocapitalization ( . none)
@@ -43,7 +43,7 @@ struct LoginScreen: SwiftUIScreen {
4343 " password " ,
4444 text: model. binding (
4545 get: \. password,
46- set: { screen in { screen . actionSink . send ( . passwordUpdated( $0 ) ) } }
46+ set: Action . passwordUpdated
4747 ) ,
4848 onCommit: { model. value. actionSink. send ( . login) }
4949 )
Original file line number Diff line number Diff line change @@ -45,4 +45,16 @@ public extension ObservableValue {
4545 }
4646}
4747
48+ public extension ObservableValue where Value: SwiftUIScreen {
49+ func binding< T> (
50+ get: @escaping ( Value ) -> T ,
51+ set: @escaping ( T ) -> ( Value . Action )
52+ ) -> Binding < T > {
53+ binding (
54+ get: get,
55+ set: { screen in { screen. actionSink. send ( set ( $0) ) } }
56+ )
57+ }
58+ }
59+
4860#endif
You can’t perform that action at this time.
0 commit comments