-
Notifications
You must be signed in to change notification settings - Fork 472
AsyncStorage.multiRemove method has different behavior on Android and iOS #6
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
Comments
Thanks @jhoobergs for raising this issue. Good catch! |
I personally don't see why calling multiRemove with an empty array should be an error - it just means that I'm not asking it to remove anything. I'm curious as to why you feel that throwing an error is the correct default? I agree that we should align the platforms! |
The current error message on Android is also a bit strange: "Error: Invalid key" without a key name because there is no key. We got a lot of these errors in our sentry and couldn't figure out where they came from. I think @hawkrives is right about not throwing an error on empty arrays. |
I prefer to get feedback about actions. If not get an error then maybe boolean value would be a way to go? To solve this issue we need to add validation to @jhoobergs would you like to fix it and send PR? I think that we should unify the way in which we validate inputs for all methods. The API behavior should be consistent. WDYT @krizzu ? |
I have no experience with Objective C, so I can't really fix it. |
I'm up for having feedback from actions - throwing an error tells us we could do something wrong. We can also make those Errors more meaningful, with hints of what might fix the issue (like "Check if the array is not empty" ). @pbitkowski Feel free to post PR |
Sure, but the API contract of "multiRemove" is "delete all of these things" - why special-case having zero items? I don't particularly relish having to add application-level checks to make sure I'm not calling with an empty array; I often build up a list of keys from some other data, and if multiRemove throws on an empty array, I'd need to check before I call it. That just seems like an odd design choice to me. |
@hawkrives Thank you for the feedback, I understand your concern.
|
@krizzu I'm going to prepare such PR soon. |
I thought about it @krizzu, and the We've got the same situation with multiSet. |
@pbitkowski @hawkrives @jhoobergs If you'd like to help with it, PR that deletes array length check on android would be awesome. Thanks for your input! |
🎉 This issue has been resolved in version 1.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
When calling the AsyncStorage.multiRemove method with an empty array, the behavior on Android and iOS is different:
I created this issue at the facebook/react-native repo: facebook/react-native#23412 where I was told to create it at this repo.
The text was updated successfully, but these errors were encountered: