aveq-research / localforage-asyncstorage-driver Goto Github PK
View Code? Open in Web Editor NEWDriver which enables you to use localforage for React-Native's AsyncStorage API
License: MIT License
Driver which enables you to use localforage for React-Native's AsyncStorage API
License: MIT License
Hi there!
Thanks a lot for this package - its really nifty. In fact I am using it as a dependency in a cache wrapper im working on :). I haven't tested this in live code, but writing jest tests for my package, I noticed something peculiar-
const AsyncStorageDriver = driverWithDefaultSerialization()
await localforage.defineDriver(AsyncStorageDriver)
await localforage.setDriver(AsyncStorageDriver._driver)
//@ts-ignore
console.log(localforage._driver) // "rnAsyncStorageWrapper-withDefaultSerializer"
const instance = localforage.createInstance()
//@ts-ignore
console.log(localforage._config._driver) // "localStorageWrapper"
Does this package support instances?
I am not able to add the instance name for the store for react native. It throws an error. Error: No available storage method found. I am trying to keep separate instance so we do not clear the entire instance the entire for that instance db.
Versions below
{
"expo": "~48.0.5",
"react-native": "0.71.3",
"@aveq-research/localforage-asyncstorage-driver": "^3.0.1",
@react-native-async-storage/async-storage": "^1.17.11",
"localforage": "^1.10.0"
}
Hello,
I am trying to use this driver for a react-native sdk. The SDK is in typescript. I have successfully implemented local forage for web sdk and now I am trying to implement this driver to be able to use local forage for the react-native sdk. I am sharing the code snippet below and the output I get when I integrate the SDK in a react-native android app.
Code:
this.keyStore = localforage.createInstance({
name: format(LOCAL_STORE.STORE_STRING, CometChat.getAppId(), LOCAL_STORE.KEYS_STORE)
});
const driver = driverWithoutSerialization();
this.keyStore.defineDriver(driver).then(
() => {
this.keyStore.setDriver(driver._driver).then(
() => {
driver._support().then(
support => {
console.log('_support', support);
console.log('keyStore', this.keyStore);
this.keyStore.keys().then(
keys => {
console.log('keys', keys);
this.keyStore.setItem('deviceId1', 'it-should-work').then(
setItem => {
console.log('setItem', setItem);
this.keyStore.getItem('deviceId1').then(
getItem => {
console.log('getItem', getItem);
}, err => {
console.log('error in getItem', err);
}
);
}, err => {
console.log('error in setItem', err);
}
);
}, err => {
console.log('error in keys', err);
}
);
}, err => {
console.log('error in support', err);
}
);
}, err => {
console.log('error in setDriver', err);
}
)
}, err => {
console.log('error in defineDriver', err);
}
);
Output:
Hi,
Version 2.0 brings a new peer dependency: @react-native-community/async-storage
. Is there a reason to use it instead of @react-native-async-storage/async-storage
?
There is a warning in @react-native-community/async-storage npm package page:
I am encountering the above SyntaxError
when running ava
tests against files which utilize this module. I am using TypeScript + ts-node
, which is probably why it complains (see TypeStrong/ts-node#505).
Would it be possible for this module to use a CommonJS require
instead of import
?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.