Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent makeCachedVar from overwriting existing value? #52

Open
seanaguinaga opened this issue May 24, 2022 · 3 comments
Open

Prevent makeCachedVar from overwriting existing value? #52

seanaguinaga opened this issue May 24, 2022 · 3 comments

Comments

@seanaguinaga
Copy link

Hello

How do you make sure that makeCachedVar doesn't overwrite the existing value if there is one in the cache?

I am not sure how you would initialize something without rewriting what is there? Is there a read-only function not in the docs?

@seanaguinaga
Copy link
Author

undefined values also seem to be written - which I saw a commit that should have made that impossible?

@danReynolds
Copy link
Collaborator

Hey @seanaguinaga ! So the default value provided to the makeCachedVar API is replacing an existing value in the cache when it shouldn't be? Yea it should only use the default value instead if there isn't a falsy value there already. Do you have a repro I can look at?

@seanaguinaga
Copy link
Author

My mistake!

I was not importing the sync version, but I was calling it synchronously.

Switched to sync and that issue is gone!

🤦‍♂️ it was one of those days

I noticed that even persistCacheSync has persistenceMapper on it, but it does not fire, is that intentional?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants