With Reflux, 2 stores or 1 store for a resource? (Bicycles / Current bike vs bike)

I am still trying to tilt my head towards the external state. Is there a general practice for setting up stores for a resource? For example my web api has:

GET /bikes
GET /bikes/:id

      

I started with BikeStore and bikes: []

. Now I am working on a ShowBike component and am not sure if I should use the BikeStore (not entirely accurate) or make a second store for individual items.

+3


source to share


1 answer


The concept of a store in Flux is a pretty simple abstraction on the client how you access the data. Separate stores should be used for different types of data. In your case, the resource is the same, there is no good reason to keep separate bike shops. Even more: individual item stores are not meant to be used and should be avoided.

From the docs thread :



Stores contain application state and logic. Their role is somewhat similar to the model in traditional MVC, but they manage the state of many objects - they do not represent a single data record like ORM models. They are also not the same as the underlying collections. More than just managing a collection of ORM-style objects, stores manage application state for a specific domain in the application.

+2


source







All Articles