Comments (11)
I would like to see this as well, for the same reasons cited in the Ian Obermiller interview.
For now, I've been working around it by putting more "smarts" into my components but I'd rather not.
from fluxible.
My understanding is that stores should not be interacting with an API. Only Action Creators should interact with the API layer according to this diagram: https://github.com/facebook/flux and this article: http://facebook.github.io/react/blog/2014/10/17/community-roundup-23.html#async-requests-with-flux-revisited .
from fluxible.
I think you're right about that but in this case, what's at issue is whether or not stores should have access to action creators or not.
from fluxible.
Exactly. The idea is that stores could call an API themselves and then call an action creator when the response has come back. This is how some other Flux implementors are doing it.
This isn't as easy as just exposing the executeAction
method to the stores though. We have to make sure that we can track when a store has completed its async calls so that we know when it's safe to render the markup on the server.
I have some ideas of how we could do that, but it would require some changes to the way that actionContext
and storeContext
work.
from fluxible.
+1. I've been thinking aloud about this in the gitter room, and @koulmomo pointed me to this. I feel it right to have the domain/store which knows the state of data to trigger the action, raise a PENDING event, and the result comes through the dispatcher. Please let me know you also felt the need of it and would be considering to implement this. thanks
A SO post where Bill Fischer and Brandon (Fluxxor) agrees with this approach.
http://stackoverflow.com/questions/26632415/where-should-ajax-request-be-made-in-flux-app
from fluxible.
write
actions instead of read
, which to me kinda makes sense. Right now we don't think we have a layer that controls data freshness (whether to pull from memory, cache, localStorage
... or fetch) and since Store
s have the data that makes it an ideal layer to have that control. Which means Store
s might need a way to fetch
data directly.
from fluxible.
👍 I was thinking about this for a bit, I like the purity of the one-way data flow. At the same time right now I'm trying to leverage flux-router-component's CHANGE_ROUTE_SUCCESS
to fetch some data.
Also the whole localStorage
vs fetch
use cases is intriguing.
Update:
I forgot that you can assign actions to routes, so that solved my problem.
from fluxible.
+1
I was about to create an issue on this myself just now. I'd be happy to help out developing this if it would speed things along.
from fluxible.
+1
from fluxible.
For use until this is supported natively in Fluxible I've created marnusw/fluxible-plugin-store-execute-action.
from fluxible.
Not sure if anybody is still thinking about this, but we went form vanilla flux -> reflux -> fluxible and from being able to dispatch action from store to stores without access to dispatch. Because you have access to stores from actionCreator context, you can always check what data you already have and decide accordingly how the action actually get the data. This makes actionCreator more complex, but reduces complexity of the store which was more beneficial for us when our application got bigger.
from fluxible.
Related Issues (20)
- Support registering services that return promises HOT 4
- Some properties are not showing. HOT 1
- compatibility with React v16 HOT 4
- An in-range update of babel-eslint is breaking the build 🚨 HOT 3
- An in-range update of sinon is breaking the build 🚨 HOT 5
- [addons-react] Following React 16.3+ new Context API ? HOT 7
- componentWillReceiveProps to getDerivedStateFromProps HOT 5
- Version 10 of node.js has been released HOT 1
- [fluxible] context.executeAction(action, null, callback) invokes the callback before the async action finishes HOT 1
- An in-range update of react is breaking the build 🚨 HOT 2
- An in-range update of react is breaking the build 🚨 HOT 25
- Should dispatch NAVIGATE_FAILURE if action is not able to resolve HOT 2
- An in-range update of eslint-plugin-react is breaking the build 🚨 HOT 12
- Update React lifecycle methods HOT 2
- [fluxible-addons-react] react 16 task list HOT 26
- TypeError: this.props.currentRoute is null HOT 2
- Render a component when error occurs HOT 1
- Question regarding debug dependency HOT 6
- Update Access the context site docs
- useStore hook HOT 6
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 fluxible.