What is the proper way to initialize data (asynchronously) with RefluxJS? Is there something similar to AngularJS' resolves, or the Flux implementation has nothing to do with this (The router should be handling this reponsibility)?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
Reflux has an API for this actually.
The docs are poor at describing it, but Spoike (Reflux's author) gave an answer along with a code example:
https://stackoverflow.com/a/28984512/1775026
In your application's top-level component, use the
comoponentWillMount
method (docs) to trigger an action that fetches the data. This method will get called when the component is initially rendered.For example: