talut / rn-secure-storage

Secure Storage for React Native (Android & iOS)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Confusing return values for `set`

LinusU opened this issue · comments

I don’t understand the “Example Fail for Set”, will the promise resolve with that value?

Returning boolean success flags is, in my opinion, very bad api design in JavaScript. Why not reject the promise with a proper error object when the call fails, and resolve it with undefined when the call succeeded?

Now I review my code android can't throw any error when a key is already removed. So I changed the code for like if is key stored/updated is succeeded message will be "Key stored/updated successfully" otherwise it will throw error. On getting stored key if succeeded will return value but otherwise it will throw error. ((under api 23) it will return null) But at removing I don't have a throwable error. So if this key returning null value that's means user already removed this. Deleting keystore is returning false that's means user already removed this. But at IOS I can't apply this kind solution I think. Now I'm working for IOS solution.

Updating to version 1.0.7 will answer your questions 😄