-
|
Hello First of all, congratulations on the great work you have accomplished with TCA. I have a question. I have been playing a bit with the CaseStudies and I stumbled across a situation I do not know if it is expected or not. In the 01-GettingStarted-FocusState case study, if I add a new handler for the binding action The log will be only printed if the Is it expected? I can think of a real world scenario in which something like this would be useful. ie, if we have to customize a complex custom TextField when it gains focus. How could we handle that in the binding is not being triggered? Thank you so much in advance |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Hi @pdrcabrod, yeah this is to be expected. If the focus changes directly in a reducer from some other action: case .buttonTapped:
state.focusedField = .title…then the If you just want to listen for any changes to CombineReducers {
BindingReducer()
Reduce { state, action in … }
}
.onChange(of: \.focusField) { … }You can look at the docs for |
Beta Was this translation helpful? Give feedback.
Hi @pdrcabrod, yeah this is to be expected. If the focus changes directly in a reducer from some other action:
…then the
.bindingaction can't possibly be destructured in theswitch. After all, a.bindingaction wasn't sent, the.buttonTappedaction was sent.If you just want to listen for any changes to
focusFieldyou can use theonChangereducer operator:You can look at the docs for
onChangefor more information of how to use it.