Skip to content
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

Closed

Conversation

mvayngrib
Copy link
Contributor

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

@facebook-github-bot facebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Jan 18, 2017
@@ -0,0 +1,10 @@

export type AsyncStorageBackend = {
clear: function,

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semi: Missing semicolon.

@@ -13,6 +13,8 @@
*/
'use strict';

import type { AsyncStorageBackend } from './AsyncStorageTypes'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semi: Missing semicolon.

@mvayngrib mvayngrib force-pushed the feature-asyncstorage-setbackend branch from ded3be6 to a835158 Compare January 18, 2017 23:03
@mvayngrib
Copy link
Contributor Author

not sure why tests failed, the errors seem to point to Alert.js, which I did not modify:

Libraries/Alert/Alert.js:20
 20: /* $FlowFixMe(>=0.38.0 site=react_native_fb) - Flow error detected during the
     ^ Error suppressing comment. Unused suppression

AsyncStorage.multiMerge = multiMerge;
} else {
delete AsyncStorage.mergeItem;
delete AsyncStorage.multiMerge;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why delete them?

Copy link
Contributor Author

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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

@mkonicek
Copy link
Contributor

To fix the tests you probably just need to rebase.

@mvayngrib
Copy link
Contributor Author

@mkonicek re: rebase, great, will do in a bit

@mvayngrib mvayngrib force-pushed the feature-asyncstorage-setbackend branch from a835158 to 937171c Compare January 31, 2017 20:29
@mvayngrib
Copy link
Contributor Author

@mkonicek checks don't seem to be moving :)

@mvayngrib
Copy link
Contributor Author

@mkonicek any hope for this PR?

@facebook-github-bot
Copy link
Contributor

@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.

@stale
Copy link

stale bot commented Oct 13, 2017

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.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Oct 13, 2017
@stale stale bot closed this Oct 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. JavaScript Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants