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

fixed a bug of sharedData.fetch. #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kaz8096
Copy link

@kaz8096 kaz8096 commented Mar 14, 2020

You can't use 0 / false for sharedData due to invalid check.
Currently the workaround is to provide altValue explicitly, such as

const d = windowmanager.sharedData.fetch('key', 0);

But of course, you may not use anything other than 0 / false as altValue if your value would have 0 or false.
(for instance, your value would be 0 ~ 100 and you want to give MAX_VALUE if the key doesn't exist --- you won't be able to solve this situation with the above workaround)

@a-sync
Copy link
Collaborator

a-sync commented Mar 15, 2020

for some reason altValue is undocumented in the readme :/

the current behaviour is: a falsy value of referenced key returns the altValue

the source doc is the following:

  • @param altValue The alternative value to return in case the passed key doesn't exist

so the condition actually should be (key in this.data) according to this, (allowing it to return different falsy values, including undefined)
but my concern is that changin the current logic can potentially break something that might depends on it

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

Successfully merging this pull request may close these issues.

2 participants