Store icon indicating copy to clipboard operation
Store copied to clipboard

[Feature Request] An ability to add entry to the cache manually

Open alaegin opened this issue 2 years ago • 0 comments

Hello!

Is your feature request related to a problem? Please describe. I think that my case is very common. Therefore I couldn't create a clean solution without library extension and/or excessive complexity.

I have two screens:

  • Posts list. I fetch List<Post> here.
  • Post details list. It's opened after the post item on the previous screen is clicked. It has the same data type Post.

My goal is to be able to receive an exact Post by its UUID (String) from the store.

Describe the solution you'd like I'd like to be able to add an entry to the cache without making network requests. In my particular case I see the following block of code:

val postsResult = dataSource.getPosts(page = postsPage)

postsResult.ifSuccess { posts: List<Post> ->
    posts.forEach { post: Post -> postsStore.put(post.id, post) }
}

Perhaps there is already another solution that I don't see?

Describe alternatives you've considered

  • I could create SourceOfTruth based on Map. It seems weird to have a Store with cache functionality and then disable, and implement own cache just it in order to have just put logic.
  • I could create any database for persisting List<Post> but it seems too complex because there's no point in persistence in my particular case because data changes frequently.

P.S. I've tried to implement this logic in 5.0.0-alpha04.

alaegin avatar Mar 12 '23 18:03 alaegin