MobileNativeFoundation / MobileNativeFoundation/Store

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

Open
#535 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Kotlin
Stars
3.4k
Forks
217
Avg merge
18m
Merged PRs (30d)
4

Description

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 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing Store cache API and the attempted implementation in version 5.0.0-alpha04. Determine how an entry could be inserted by UUID without a network request, then verify that the resulting Post can be retrieved through the normal store flow.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.