Flux Singleton Stores and searching, pagination etc.

(Mirek Sz) #1

In Flux implementation stores are singletons but how to manage for example searching or pagination.

I saw solution where I have CustomersStore which contains all customers from db and searching was resolved by reducing functions but in real world holding all data in Store is immposible.

Another aproach could be create CustomersSearchAction and CustomerStore can react on this action by replacing current state with new filtered state and emit event to components about data change but in this solutions I have problem with components isolation for example 3 components presenting data connected with 1 store and only in one componet searching occurs…

Maybe someone have some real world example with searching and pagination

Currently I have CustomersStoreFactory which create one CustomersStore per component

(Björn L) #2

I’ve got exactly the same question but around mobx-state-tree stores, which usually also are based on a singleton root store holding all the domain object data in a hierarchy of objects.

I struggle to see how I would fit in a SearchQueryStore or a PaginationStore in this structure? What would they do? How do I make sure that they can be reused to render several different queries on the screen at the same time?