electron-window-manager icon indicating copy to clipboard operation
electron-window-manager copied to clipboard

fixed a bug of sharedData.fetch.

Open kaz8096 opened this issue 5 years ago • 1 comments

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)

kaz8096 avatar Mar 14 '20 19:03 kaz8096

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

a-sync avatar Mar 15 '20 00:03 a-sync