-
Notifications
You must be signed in to change notification settings - Fork 24.6k
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
add AsyncStorage.setBackend to support custom backends #11972
Conversation
@@ -0,0 +1,10 @@ | |||
|
|||
export type AsyncStorageBackend = { | |||
clear: function, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null: Parsing error: Unexpected token
1 |
2 | export type AsyncStorageBackend = {
3 | clear: function,
| ^
4 | getAllKeys: function,
5 | multiGet: function,
6 | multiSet: function,
}); | ||
}, | ||
setBackend: function ( | ||
backend: AsyncStorageBackend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
semi: Missing semicolon.
Libraries/Storage/AsyncStorage.js
Outdated
@@ -13,6 +13,8 @@ | |||
*/ | |||
'use strict'; | |||
|
|||
import type { AsyncStorageBackend } from './AsyncStorageTypes' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
semi: Missing semicolon.
ded3be6
to
a835158
Compare
not sure why tests failed, the errors seem to point to Alert.js, which I did not modify:
|
AsyncStorage.multiMerge = multiMerge; | ||
} else { | ||
delete AsyncStorage.mergeItem; | ||
delete AsyncStorage.multiMerge; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why delete them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkonicek nothing changed in this respect, this is old code
// Not all native implementations support merge. | ||
if (backend.multiMerge) { | ||
AsyncStorage.mergeItem = mergeItem; | ||
AsyncStorage.multiMerge = multiMerge; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the other methods such as getAllKeys
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkonicek same as above. I don't want to mix a bunch of different changes in one PR
To fix the tests you probably just need to rebase. |
@mkonicek re: rebase, great, will do in a bit |
a835158
to
937171c
Compare
@mkonicek checks don't seem to be moving :) |
@mkonicek any hope for this PR? |
@mvayngrib I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions. |
Q: What existing problem does the pull request solve?
A: I want to use a custom backend for AsyncStorage, specifically: https://www.npmjs.com/package/react-native-async-storage-snappy on Android and https://www.npmjs.com/package/react-native-async-storage-rocks on iOS
The latter doesn't require any changes because it anticipates the presence check for a native module called AsyncRocksDBStorage, but the former is currently impossible without ugly tricks like NativeModules.AsyncRocksDBStorage = NativeModules.AsyncSnappyStorage
the change is pretty small (mainly the setBackend method itself and the addition of AsyncStorageTypes.js). It looks big because I had to move out mergeItem and multiMerge from the AsyncStorage object