Closed jans-y closed 4 years ago
The state, Actions and Connectors get coupled in AsyncRedux, I don't see a way around it. Maybe there is, but since I have never tried to do what you describe, I couldn't give you an answer without studying the problem in detail, which I can't do right now.
At first glance I don't see a problem on creating a different store for the login sequence, since it's very separate from the rest of the program. If it were not, your approach definitely wouldn't work, since LoginState get loginState => loginStore.state;
would act like a mutable state in the eyes of the main store. This means, if your LoginState
is changed by your login-store, the main store wouldn't know about this change, and wouldn't rebuild the widgets, for example.
Maybe a better approach is to have the two different stores completely apart. When the login sequence finishes it can call store.setLoginStateAction(loginStore.state) to put the state into the normal store.
Fun fact: When I was first learning about Redux I had a kind of similar question: https://stackoverflow.com/questions/49621633/using-flutter-and-redux-flutter-redux-how-can-i-uncouple-widgets-from-the-app
Hi,
We are working on two very similar apps sharing a lot of logic and a common backend.
We would like to extract our login screens and corresponding logic (actions) into a package and import it into both apps.
The problem is how to get the app's AppState inside the package logic:
The only solution we came up with is to have a separate store inside the package something like LoginState and then use it like this
module:
app:
Thank you.