react-native-simple-store

1.3.0 • Public • Published

React Native Simple Store

Code Climate Build Status npm version npm

A minimalistic wrapper around React Native's AsyncStorage.

Installation

npm install react-native-simple-store

API Reference

Example Usage

import store from 'react-native-simple-store';
 
store
  .save('coffee', {
    isAwesome: true
  })
  .then(() => store.get('coffee'))
  .then(coffee => {
    console.assert(coffee.isAwesome === true);
  })
  .then(() => store.update('coffee', {
    isNotEssential: false
  }))
  .then(() => store.get('coffee'))
  .then(coffee => {
    console.assert(coffee.isNotEssential === false);
    console.assert(coffee.isAwesome === true);
    return store.delete('coffee');
  })
  .then(() => store.get('coffee'))
  .then(coffee => {
    console.assert(coffee === null);
  })
  .catch(error => {
    console.error(error.message);
  });
 
// using the .push method for storing arrays
store
  .save('coffeeTraits', ['rich'])
  .then(store.push('coffeeTraits', 'smooth'))
  .then(store.get('coffeeTraits'))
  .then(console.log) // ['rich', 'smooth']

License

MIT

install

npm i react-native-simple-store

Downloadsweekly downloads

3,578

version

1.3.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability