Giter Site home page Giter Site logo

Comments (15)

brianegan avatar brianegan commented on June 20, 2024 3

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.

brianegan avatar brianegan commented on June 20, 2024 2

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 clear
  • onDidChange - good alignment with the onWillChange 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.

kitoko552 avatar kitoko552 commented on June 20, 2024 1

I got the same problem as hash404 got. I agree with Alexandre.
I'm looking forward to updating!

from flutter_redux.

brianegan avatar brianegan commented on June 20, 2024

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.

AlexandreRoba avatar AlexandreRoba commented on June 20, 2024

Any update on this?

from flutter_redux.

AlexandreRoba avatar AlexandreRoba commented on June 20, 2024

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.

brianegan avatar brianegan commented on June 20, 2024

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.

AlexandreRoba avatar AlexandreRoba commented on June 20, 2024

Hey Brian, IMHO onDidChange speaks for itself :)

from flutter_redux.

brianegan avatar brianegan commented on June 20, 2024

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.

AlexandreRoba avatar AlexandreRoba commented on June 20, 2024

from flutter_redux.

brianegan avatar brianegan commented on June 20, 2024

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:

  1. The first time the ViewModel is created and the builder function is run.
  2. Every time the ViewModel changes (not the App State necessarily, as you could use distinct to limit the number of rebuilds for performance reasons)
  3. 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:

  1. Merge these two callbacks into onBuildViewModel or something like that
  2. Keep them separate: onFirstBuild and onDidChange.

from flutter_redux.

AlexandreRoba avatar AlexandreRoba commented on June 20, 2024

from flutter_redux.

brianegan avatar brianegan commented on June 20, 2024

Cool, thanks again. That was my gut feeling as well, so I'll go that route.

from flutter_redux.

dviluk avatar dviluk commented on June 20, 2024

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:

  1. The first time the ViewModel is created and the builder function is run.
  2. Every time the ViewModel changes (not the App State necessarily, as you could use distinct to limit the number of rebuilds for performance reasons)
  3. 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.
  1. also when you open the keyboard

from flutter_redux.

brianegan avatar brianegan commented on June 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.