Comments (5)
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.
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.
@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.
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.
@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)
- Cannot dispatch in the middle of a dispatch. HOT 1
- New Flux store instance created upon second component referencing store HOT 7
- Flux Utils + Hooks HOT 6
- TypeError: Class constructor App cannot be invoked without 'new' HOT 1
- Using version of fbjs that depends on unsupported core-js module HOT 2
- Please update the following components: FluxContainer(containerClass) React 16.10.2 HOT 5
- how do we differ from Architecture and pattern? HOT 1
- Is this code a good way to update react component from dispatch in OOP class object? HOT 2
- Flux container breaks class methods defined with class properties syntax HOT 1
- Container create context issues after Babel 7.9.x update. HOT 5
- CVE-2020-15168 found in [email protected] HOT 13
- CVE-2020-7733 vulnerability by linking to an older fbjs version HOT 2
- Is fbemitter project discontinued? Is flux? HOT 1
- Add React 17 support
- NPM reports flux vulnerabilities HOT 3
- CVE-2021-27292: ua-parser-js needs to upgrade to 0.7.24 HOT 4
- mock flux store - react test HOT 2
- Will there be a Chinese version? HOT 1
- Video goes off screen and does not fit neatly HOT 1
- Add react-18 as peer dependency. HOT 1
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 flux.