How to trigger binding action intentionally? #1841
-
Let's suppose that we have two case .binding(\.$userID):
/* some local validations... */
enum RequestUserNameID { }
return env.checkUserName(state) // validates with server
.map(Action.fetchCheckUserID)
.cancellable(id: RequestUserNameID.self, cancelInFlight: true)
case .binding(\.$userEmail):
/* some local validations... */
enum RequestUserEmailID { }
return env.checkUserEmail(state) // validates with server
.map(Action.fetchCheckUserEmail)
.cancellable(id: RequestUserEmailID.self, cancelInFlight: true) I just want to trigger these binding actions intentionally, without modifying TextFields. Any ideas will be very appreciated. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @Jager-yoo! It would be |
Beta Was this translation helpful? Give feedback.
Hey @Jager-yoo! It would be
.binding(.set(\.$userEmail, "something"))
, but you can maybe also refactor your domain to produce the same effect than the one fromcase .binding(\.$userEmail)
using private functions. Re-emitting actions to reuse code is indeed inefficient, as you can read in the "Performance" article.