MobileNativeFoundation / Store

A Kotlin Multiplatform library for building network-resilient applications
https://mobilenativefoundation.github.io/Store/
Apache License 2.0
3.18k stars 203 forks source link

[Question] Data with nested keys #568

Closed gregkerzhner closed 1 year ago

gregkerzhner commented 1 year ago

Question - does Store & MutableStore have the ability to handle data which has nested keys? The classic example would be:

A list of TODO objects (key "todoslist") A single TODO object in that list (key "todo{id}")

A common API structure in this setup might be to have a GET "/todos" endpoint which fetches the whole list, and then a PUT "/todo/id" endpoint which updates a single TODO.

With this setup, consider the Store doing the following operations:

  1. get "todos_list" from the server
  2. Update some data on "todo_1"
  3. get "todos_list" from the server again.

In the above example, since the key for "todo_1" is different than "todos_list", would Store not detect a conflict between operations 2 and 3, meaning that operation 3 would potentially overwrite operation 2's data? What is the recommended way to use Store to handle this kind of situation?

Thanks!

matt-ramotar commented 1 year ago

Hey @gregkerzhner Sorry to be slow. Very busy few weeks. Documentation is WIP but if I am understanding correctly I'd recommend using Store5 with MultiCache. Check out these: