-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store not updating state #111
Comments
Hey hey :) Glad it's useful, and welcome to the land of Flutter! Hope you're enjoying it! Now, this is a bit tough to debug without the full source, but is there any way you're recreating the If it were me, that's probably the first place I'd be looking. Furthermore, it might be a good idea to add the Let me know if that helps! |
Man that was quick,
I don't know that much dart yet but I imagined it's only changing that property. You know what, it's a public repo, I'm making a push now with my changes. It's here: https://github.com/ArthurianX/g4media-mobile/commits/master |
So, it's a mess in that repo, I've started my work based on one of your demos, and I'm gradually understanding things. |
Nope, that means that it's constructing an entirely new instance of the State each time and wiping out any previous state. In general, I use a And I use it like so: final myState = MyState(loading: false, pageOffset: 0);
// Start Loading
myState.copyWith(loading: true); // Create a new instance but only updates loading status
// Page Update when data comes back
myState.copyWith(loading: false, pageOffset: myState.pageOffset + 1); |
Really cool! Thanks! I'll have to do some refactoring! Looking at your examples, from what I understand you are copying and passing the WHOLE state around on each dispatch and all the places you call it from, is this ok ? I'm asking this because in my case I'm planning to save ~100 articles in my state, and copying it around like that on each action call seems ... heavy. Am I wrong? |
Yep, this shouldn't be a big deal. In the Todos example, if the action does not affect a part of the substate it will return the OLD value. Therefore, it's not re-creating that data, it's just passing the old reference to the new State instance! Therefore, the Glad it was helpful :) |
Thanks a lot @brianegan ! Have a great day! |
Sure thing, you too! |
Hey @brianegan !
This is a cool library, I have a problem and I'm not sure it's a flutter_redux issue or human error.
I have a store, in which I keep a
pageOffset: 0
value, I'm using that to fetch paginated data from an api.The flow is like this:
At this point, I scroll at the bottom of my list, and a new PAGED action is triggered to get me the next page of items
pageOffset
by 11
, as it should beNow, I'm scrolling again to the bottom and fetch the next page, but
pageOffset
is0
.I'm not sure what I'm missing here's some snippets of code:
Store / State
Part of the PAGED middleware ]
Reducer:
My opinion is that the state is not updated by the time I scroll down again (it's not a time/repaint thing, I can wait however long)
Also, this is my first week with Flutter, I might be misunderstanding something really basic.
Thanks!
The text was updated successfully, but these errors were encountered: