Lists
How can you keep a list in order?
Redux Resource currently only provides lists as a way to keep track of the initial sort order returned from a single request. As more requests are made against a single list, it will not respect any particular order.
If you'd like to maintain ordering of some kind within a specific list, or all of your lists, then we recommend writing a plugin to handle that.
Can lists be used for keeping track of client-side lists of resources?
Yes, they can. Use the UPDATE_RESOURCES
action type to manage client-side things.
How do you know when to use dynamically-named lists or not?
In the majority of situations, you won't need to use dynamic lists. For instance, if you are building a banking application that lets a user display transactions for each of their bank accounts, you might think to make a list for each one, like this:
transactionsFor${accountId}
There are situations when this could be useful. For instance, if you wish to display the transactions of many bank accounts onscreen at once. Most applications, though, only let the user see one set of transactions per account at once. Therefore, it's much better to just use a single list.
transactionsForAccount
As the user moves between pages in the application, you can set mergeListIds
to false
to throw away the previous list, and start fresh.
Concerned about caching? That should be handled at the request level instead. Check out the caching recipe for more.
If you need animations, then you may consider using dynamic lists or a solution like freezus to "freeze" the state of the outgoing component.
Why is mergeListIds
set to true
in request actions by default?
mergeListIds
set to true
in request actions by default?There are a few reasons.
It's nice that all of the
mergeX
attributes of the CRUD actions aretrue
by default.Multiple requests can contribute to a list. For instance, a user may read a list of
favorites, and then create a new favorite. In this situation, we have multiple requests
contributing to the same list, so it's good that the resources are merged, rather than
replaced.
We understand that mergeListIds
is one of those attributes that you'll frequently be setting to false. We believe the reasons above justify keeping it true
by default, but if you disagree, feel free to open an issue and we'd be happy to discuss it further with you!
Last updated