GithubHelp home page GithubHelp logo

Comments (5)

sterpe avatar sterpe commented on April 20, 2024

Yeah, had the same concern, I wrote a pure async dispatcher (it's pretty beta) but supports recursive dispatching in the correct order, while ensuring that there are no browser redraws until all affected views have updated.

You can check it out here, maybe it would work for you too.

https://www.npmjs.org/package/quantum-flux

from flux.

fisherwebdev avatar fisherwebdev commented on April 20, 2024

We enforce this to ensure that a single action has caused all of the relevant stores to update themselves before moving forward with the next round of updates. Flux was originally created to deal with derived data: dependencies between stores. So if Store A needs to get data from Store B, and both stores respond to an particular action, we need to make sure that both of these have updated before they can get updated again. Otherwise, we are getting into a race condition. Instead we enforce that the state of the all the stores remain in sync.

The design of the application (and the cognitive overhead) becomes much simpler when you cannot invoke a new dispatch while another dispatch is still occurring. It also forces you to always work with the singular flow of actions -> dispatcher -> stores -> views. If you have data flowing through the stores and views in any other way, then you are not conforming to that singular data flow, and your application will get messy as it grows larger and more complex.

An action queue would not be a bad solution if you have multiple async API calls coming back at the same time. We are actually working on an action queue on the other end -- the store end, after the dispatches have occurred -- to maintain an action history for the purpose of optimistic updates. However, the same concept could get implemented at the point of the dispatcher, to manage the situation you are describing. The important thing would be to ensure, however, that two dispatches were not happening at the same time.

The dispatcher does expose a isDispatching() method that you could utilize in your action queue.

from flux.

fisherwebdev avatar fisherwebdev commented on April 20, 2024

@sterpe quantum-flux looks like it has a lot of great ideas in it. I'll take a deeper look, but the docs are nicely written and very understandable.

from flux.

mosch avatar mosch commented on April 20, 2024

thanks for your replies! i'm excited to see the action queue at the stores - i'll have my own dispatching queue for now. thank you guys.

from flux.

achobanov avatar achobanov commented on April 20, 2024

@fisherwebdev Thanks for your reply. Let's imagine I have multiple instances of the same component, which must fire an action inside componentDidMount. All of those components are rendered from an array of data objects ( simultaneously ). How should I implement this? I am using Alt, but their docs say they use your dispatcher, so I figured I should ask here as well. Thanks

from flux.

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.