Skip to content

fixed a bug of sharedData.fetch.#78

Open
kaz8096 wants to merge 1 commit intotamkeen-tms:masterfrom
kaz8096:fix-sharedData-fetch
Open

fixed a bug of sharedData.fetch.#78
kaz8096 wants to merge 1 commit intotamkeen-tms:masterfrom
kaz8096:fix-sharedData-fetch

Conversation

@kaz8096
Copy link
Copy Markdown

@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
Copy Markdown
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