Replies: 1 comment
-
Hey @marco-evc! Scope(state: \.secondView, action: /RootAction.secondView) {
SecondDomain()
} To activate the And now the tricky question: how to initialize a state for the next screen. Your solution to update the value when the button is tapped is probably OK. As an alternative, you can model your second screen using an optional state. It means that you should replace .ifLet(\.secondView, action: /RootAction.secondView) {
SecondDomain()
} added after
in your While it should already work implemented like this, you now have two ways to describe the presence or not of the destination: the optionality of var showNext: Bool {
get { self.secondView != nil }
set {
if !newValue, self.secondView != nil {
self.secondView = nil
} else if newValue, self.secondView == nil {
self.secondView = .init(text: self.text)
}
}
} But this will prevent you to use a property wrapper, hence viewStore.binding(get: \.showNext, send: RootDomain.RootAction.showNext) to control your navigation link's active state (please note that this approach with a The advantage of this approach is that you don't have a I hope it helps. |
Beta Was this translation helpful? Give feedback.
-
Hi, I started using TCA a few weeks ago, but I have a couple of questions.
1.- What is the best way to initialize a state for the next screen?
2.- In another screen I have an email and password and the login button status is activated only when the email and password are not empty. Previously I did it with Publishers.combineLatest, however in TCA I don't know how I can do something similar.
Below is the example of how I am doing point 1:
Reducer
View
And then this is my second view:
The phone number or whatever text that I set in the first view is working in the second view, but I'm not sure if this is the best way to do that.
Also In the second view I have another textfield however when I try to write anything, I get this error in the console:
I'm not sure why I am getting that error because the BindingReducer is added.
I hope the explanation of the problems I am having is accurate. Thank you very much for your help.
Beta Was this translation helpful? Give feedback.
All reactions