A wrapper for React-Native's AsyncStorage.
npm i --save react-native-storage-wrapper
import storage from "react-native-storage-wrapper";
storage.get("key"); // --> returns a Promise
storage.set("key", "value"); // --> returns a Promise
storage.del("key"); // --> returns a Promise
Usage with asteroid
import {createClass} from "asteroid";
import storage from "react-native-storage-wrapper";
const Asteroid = createClass();
// Connect to a Meteor backend
const asteroid = new Asteroid({
endpoint: "ws://localhost:3000/websocket",
storage: storage
});
Fetches key from AsyncStorage
with method getItem
.
key
String required:key
to fetch inAsyncStorage
A Promise
object. If there is any, throw an Error
Sets value for key from AsyncStorage
with method setItem
.
-
key
String required:key
saved inAsyncStorage
-
value
String required:value
saved inAsyncStorage
Remove item with selected key
from AsyncStorage
with method removeItem
.
key
String required:key
to remove fromAsyncStorage