-
Notifications
You must be signed in to change notification settings - Fork 82
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
[ENHANCEMENT] Remove async storage from the core implementation #952
Comments
Hi @matinzd, thank you for raising the issue.
To not force the user to provide a persistenceCache implementation, we use react-native-async-storage by default. I assume you mean react-native-async-storage is imported statically even if a persistentCacheProvider is provided, requiring the user to install react-native-async-storage even though it is not being used. I see that is the case in the sdk source code. I agree that we should load it dynamically instead. We are looking into it. |
A possible way/workaround for this is to import async storage in the try/catch block with a local variable in a helper class and export it to other parts of the sdk. In that case you can keep the default implementation without forcing users to install async-storage. let AsyncStorage = null
try {
AsyncStorage = require('@react-native-async-storage/async-storage').default
} catch (e) {
console.warn('AsyncStorage is not available')
}
export AsyncStorage; |
@matinzd Thanks for the suggestion. We will consider something similar to this. |
Description
It would be ideal not to tightly integrate async storage within the SDK, allowing us to inject other types of storage options. There is an object called
persistentCacheProvider
, but it appears that even if we pass inpersistentCacheProvider
, the SDK still defaults to usingasync-storage
. Perhaps lazy-loading async storage would be a better option, or not including it as a peer dependency at all.Benefits
It is possible to use faster and more modern storage options in react native like mmkv or secure storage.
Detail
No response
Examples
No response
Risks/Downsides
No response
The text was updated successfully, but these errors were encountered: