Coder Social home page Coder Social logo

Store Dependencies about flummox HOT 2 CLOSED

acdlite avatar acdlite commented on July 28, 2024
Store Dependencies

from flummox.

Comments (2)

acdlite avatar acdlite commented on July 28, 2024

I assume you're using React Router? Have you checked out the async-data example? https://github.com/rackt/react-router/blob/master/examples/async-data/app.js

In that example, the static method fetchData() returns a promise for data to be added to the topmost handler as props. With Flux, I've been using a modified version of this, where you return a promise that resolves after any async actions have completed. That way you can do whatever async operations you need to do to prepare your stores. Here's a simple example: https://github.com/acdlite/flummox-isomorphic-demo/blob/master/src/shared/components/StargazerGridHandler.js#L14-L18

This pattern is pretty useful, so I wrote a helper: https://github.com/acdlite/flummox-isomorphic-demo/blob/master/src/shared/performRouteHandlerStaticMethod.js

For complex dependencies like the one you described, you just have to make sure you chain your async operations together using either then() or async-await.

Server-side data fetching is the least developed part of Flux in my opinion, which is why I'm so pumped for Relay.

from flummox.

nickdima avatar nickdima commented on July 28, 2024

Yeah that's the current setup I have also. React router + static route handler like in your example. The problem I had was making one route handler wait on another when you have sub-routes. Anyway I have an idea that I might try.

Yeah Relay looks awesome and makes more sense then Flux for fetching data that doesn't change much over time. I'm also excited about it but the problem will be implementing it with current "legacy" backends.

from flummox.

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.