Comments (15)
Hey all, just pushed up a new PR that adds two callbacks for this purpose. Please see #55 and let me know your thoughts on the naming!
from flutter_redux.
Hey all -- what would you like this callback to be called? What I can think of:
onPostFrame
- this is the system callback used on the hood, but maybe not very clearonDidChange
- good alignment with theonWillChange
callback
Other suggestions welcome!
Also, one more question: Would you want this callback to run after the First build and after every state change, or only after the state changes?
from flutter_redux.
I got the same problem as hash404 got. I agree with Alexandre.
I'm looking forward to updating!
from flutter_redux.
Ah, this is an interesting case. We have the onWillChange
property on the StoreConnector
, but I haven't quite implemented this functionality just yet and I do know it's important. I'll look at good ways to handle this.
from flutter_redux.
Any update on this?
from flutter_redux.
I'm also kind of stuck on this. I need to set the position on a ListView on the "selected" item when the presenter is built. Unfortunattely the only way to scroll the ListView is to use a ScrollController... The ScrolleContoller can only be called once it has been attached to the ListView which happens in the build method. I'm setting a Timer in the build method that will animate the listview 10ms after is has been built... But this is ugly :(
from flutter_redux.
Hey @AlexandreRoba -- sorry, not sure how I missed your message. I'm actually playing around with this right now, and hope to publish something this weekend!
from flutter_redux.
Hey Brian, IMHO onDidChange speaks for itself :)
from flutter_redux.
Thanks @AlexandreRoba -- Would you want this callback to run after the First build and after every state change, or only after the state changes?
Or should I make 2 callbacks: onFirstBuild
and onDidChange
? Or is the onFirstBuild
even necessary? Just trying to support the important use-cases!
from flutter_redux.
from flutter_redux.
Hey hey, thanks again for all your feedback -- yah, it's a bit tricky since there are some intricacies in how builds are handled in Flutter. There are 3 types of builds that could happen:
- The first time the ViewModel is created and the
builder
function is run. - Every time the ViewModel changes (not the App State necessarily, as you could use
distinct
to limit the number of rebuilds for performance reasons) - Whenever Flutter decides it needs to rebuild the Widget. This could happen if the user rotates the screen, or if a Widget above the
StoreConnector
request a rebuild, or if the user navigates to a new route. This one is largely out of our hands and depends on the individual app / how Flutter rebuilds.
I could add callbacks for the first 2 instances, but not the 3rd. I could either:
- Merge these two callbacks into
onBuildViewModel
or something like that - Keep them separate:
onFirstBuild
andonDidChange
.
from flutter_redux.
from flutter_redux.
Cool, thanks again. That was my gut feeling as well, so I'll go that route.
from flutter_redux.
brianegan commented 8 days ago
Hey hey, thanks again for all your feedback -- yah, it's a bit tricky since there are some intricacies in how builds are handled in Flutter. There are 3 types of builds that could happen:
- The first time the ViewModel is created and the builder function is run.
- Every time the ViewModel changes (not the App State necessarily, as you could use distinct to limit the number of rebuilds for performance reasons)
- Whenever Flutter decides it needs to rebuild the Widget. This could happen if the user rotates the screen, or if a Widget above the StoreConnector request a rebuild, or if the user navigates to a new route. This one is largely out of our hands and depends on the individual app / how Flutter rebuilds.
- also when you open the keyboard
from flutter_redux.
Hey all -- this change has now been published as part of flutter_redux 0.5.2. Please play around and let me know whatcha think / if ya run into trouble :)
from flutter_redux.
Related Issues (20)
- [Question]: Mixing global and local state
- How to not accept change notifications when the Router is not at the top level, and then take the initiative to obtain the changes when the Router returns to the top level HOT 1
- onDidChange called twice HOT 8
- Is this package still actively maintained?
- `onWillChange` and `onDidChange` errors are swallowed HOT 4
- Warning related to `?` operator on Linux/Dev channel. HOT 2
- Import Store data type
- Widgets binding error after upgrading flutter version to 2.13.0-0.1.pre HOT 1
- onDidChange not working as expected HOT 3
- Build warning with Flutter 3.0 HOT 5
- flutter_redux depends on flutter_redux, version solving failed HOT 3
- onWillChange and onDidChange called twice after state update HOT 2
- Passing Store as an argument to MethodChannel and Background Isolate
- Question on how to use the reducer right way HOT 2
- [Question]: Any thoughts on difference between ignoreChange and distinct?
- Socket and Flutter_redux HOT 18
- Dispatching an action that does not alter state rerenders the widget, causing an infinite loop HOT 5
- How to watch redux store change inside useEffect? HOT 5
- [Question] is it expected that the store doesn't run until frames render? HOT 1
- After push a new page, and Dispatching an action, there is an infinite loop
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_redux.