You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A piece of my mind:
button click >>> dispatch >>> action(now,i use Future at there) >>> update state
but,There are some problems here at
final userReducer = combineReducers([
TypedReducer<UserModel, LoginByUserNameAction>(_loginByUserNameAction),
]);
Maybe I'm thinking the wrong way,so can you help me。
and my english is to bad。
。。。。。
In general, reducers must be sync and they should not perform side-effects, such as loading data asynchronously from a database, web service, or login service. For those cases, use Middleware.
I'd recommend reading through the Docs we have on the Redux package to get an idea of how all these pieces fit together:
class UserModel {
String userName;
String password;
String token;
List roles;
UserModel({
this.userName,
this.password,
this.token,
this.roles,
});
factory UserModel.setUserInfo(String username,String password, String token,List roles) => UserModel(
userName: username,
password: password,
token: token,
roles: roles
);
}
final userReducer = combineReducers([
TypedReducer<UserModel, LoginByUserNameAction>(_loginByUserNameAction),
]);
Future _loginByUserNameAction(UserModel user, action) async {
var result = await loginByUsername(action.user.userName, action.user.password);
return UserModel.setUserInfo('123', 'password', 'token', []);
}
class LoginByUserNameAction {
final UserModel user;
LoginByUserNameAction(this.user);
}
The text was updated successfully, but these errors were encountered: