Qiming
Qiming

Reputation: 1744

Flux store depends on an asynchronous download in another store

I'm learning React and flux.

Say there's a route like

// Route
/continent/:continentId/countries
// Example
/continent/europe/countries

There are two stores, a ContinentsStore and a CountriesStore

What's the best design pattern, in Flux, so that when the route is loaded, the ContinentsStore asynchronously fetches a list of all the continents, sets the current one to Europe, and then CountriesStore looks for the current continent in ContinentsStore, then proceeds to download a list of all the countries in that Continent.

Specifically, where are the action creators, and what might the actions types be?

Thanks.

Upvotes: 0

Views: 165

Answers (1)

shadeglare
shadeglare

Reputation: 7536

There is an aggregation store concept in reflux.js. So one store can listen to another one and provides additional logic that depends on data changes in an observable store. This approach is useful for data aggregation and chaining operations.

Upvotes: 1

Related Questions