SyncStorage
Synchronous storage for
React Native AsyncStorage.
Get Started
Installation
yarn add sync-storage
Usage
import SyncStorage from 'sync-storage';
SyncStorage.set('foo', 'bar');
const result = SyncStorage.get('foo');
console.log(result);
Methods Available
init()
Init prepares the SyncStorage to work synchronously, by getting all values for all keys previously
saved on RN AsyncStorage. See the example:
const data = await SyncStorage.init();
console.log('AsyncStorage is ready!', data);
get(key: string)
Returns the value of key.
SyncStorage.get('foo');
set(key: string, value: Any type)
It saves the value on memory and on the AsyncStorage.
SyncStorage.set('foo', 'bar');
SyncStorage.get('foo');
It also returns a Promise for post verification.
SyncStorage.set('foo', 'bar')
.then(() => {
SyncStorage.get('foo');
})
.catch(error => {
console.log(error);
});
remove(key: string)
It removes the value from the memory and from the AsyncStorage.
SyncStorage.remove('foo');
It also returns a Promise for post verification.
SyncStorage.remove('foo')
.then(() => {
SyncStorage.get('foo');
})
.catch(error => {
console.log(error);
});