Skip to content

mondora/react-native-storage-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm version Build Status codecov.io Dependency Status devDependency Status peerDependency Status

react-native-storage-wrapper

A wrapper for React-Native's AsyncStorage.

Install

npm i --save react-native-storage-wrapper

Usage

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
});

API

.get("key")

Fetches key from AsyncStorage with method getItem.

Arguments
  • key String required: key to fetch in AsyncStorage
Returns

A Promise object. If there is any, throw an Error


.set("key", "value")

Sets value for key from AsyncStorage with method setItem.

Arguments
  • key String required: key saved in AsyncStorage

  • value String required: value saved in AsyncStorage


.del("key")

Remove item with selected key from AsyncStorage with method removeItem.

Arguments
  • key String required: key to remove from AsyncStorage