Now I am setting the state in reducer like this using fish redux:
HomeListDefaultState _onSetArticleIds(HomeListDefaultState state, Action action) {
final HomeListDefaultState newState = state.clone();
ArticlePayload payload = (action.payload as ArticlePayload);
newState.articleListState.articleIds = payload.articleIds;
newState.articleRequest = payload.articleRequest;
newState.currentStoriesType = state.currentStoriesType;
if (payload.articleRequest.pageNum == 1 && payload.articleIds.isNotEmpty) {
newState.articleRequest.offset = payload.articleIds.reduce(max);
}
return newState;
}
when I dispatch an action in effect like this:
Future initArticles(Action action, Context<HomeListDefaultState> ctx) async {
HomeListDefaultState homeListDefaultState = ctx.state;
ArticleRequest articleRequest = homeListDefaultState.articleRequest;
articleRequest.pageNum = 1;
articleRequest.offset = null;
List<int> ids = await Repo.getElementIds(articleRequest);
if (ids != null) {
ctx.dispatch(HomeListDefaultActionCreator.onSetArticleIds(ids, articleRequest));
}
}
sometimes the state change not trigger the page rerender(when the UI not rerender and just only dispatch action), why the UI not rerender when dispatch action? so how the fish redux to konw the state changed(if the newState.articleListState.articleIds
have 10 element and replaced by new another 10 element, it will treated as changed or not)?
question from:
https://stackoverflow.com/questions/65896245/how-to-know-the-state-is-changed-in-flutter-in-fish-redux 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…