You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the recommendation for sorting data when using a CollectionDataProvider? Do you have to use a different CollectionDataProvider or cache key for each possible sort order? Or maybe you maintain your own sorted list of objects that is updated whenever the CollectionDataProvider changes?
The text was updated successfully, but these errors were encountered:
If you use the same cacheKey, you'd end up overwriting your old versions of the data in the cache (and other data providers). I assume this isn't what you want. It sort of depends what you want here...is there 1 main order, and then you want to sort into multiple things on top of that?
If that's the case, I'd just write a wrapper on top of your data provider to provide a sort order (I think this is similar to your second idea).
Or, you could cache all the different sort orders with different keys. However, this means you won't get insertion/deletion updates because you no longer share the same cache key.
Thanks. I ended up just sorting the data before calling setData. When the sort order needs to change, I just sort it and call setData again. My use case is pretty simple right now. I only have one view for displaying the data, so there are no conflicts with different data providers. I'm coming from Core Data, where you can have multiple NSFetchedResultsControllers each with different sorting, yet they all get notified when insertion/deletion/updates happen. When I need that functionality, I will need to revisit this. I'm trying RocketData to see if I can use it instead of Core Data or Realm. I like the lightweight nature of it and its immutable models. But I also realize it's not a real database like Core Data, so I might run into use cases that are difficult.
What is the recommendation for sorting data when using a CollectionDataProvider? Do you have to use a different CollectionDataProvider or cache key for each possible sort order? Or maybe you maintain your own sorted list of objects that is updated whenever the CollectionDataProvider changes?
The text was updated successfully, but these errors were encountered: