# asyncstoragehandler

> Handler for React Native AsyncStorage.

Latest version **1.0.4** (published 2018-06-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install asyncstoragehandler
pnpm add asyncstoragehandler
yarn add asyncstoragehandler
bun add asyncstoragehandler
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2018-06-24 |
| First published | 2018-06-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 49 |
| Author | Musa Joshua |
| Maintainers | musatech |
| Keywords | AsyncStorage, React, React-Native |

## Links

- npm: https://www.npmjs.com/package/asyncstoragehandler
- Repository: https://github.com/musatech/AsyncStorage-Handler
- Homepage: https://github.com/musatech/AsyncStorage-Handler#readme
- Issues: https://github.com/musatech/AsyncStorage-Handler/issues
- npm.io page: https://npm.io/package/asyncstoragehandler

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2018-06-24
- 1.0.2 — 2018-06-24
- 1.0.1 — 2018-06-23
- 1.0.0 — 2018-06-23

## README

# AsyncStorage Handler

An improved form of working with [react-native](https://github.com/facebook/react-native) asyncstorage.

## Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

### Prerequisites

This handler works strictly with react native. Works with both the

```javascript
create-react-app <app-name>
```
and the 

```javascript
react-native init <app-name>
```
of react native.


### Installing

To Install the handler 

```javascript
npm install asyncstoragehandler --save
```

## Usage

1.Import asyncstoragehandler:

```javascript
import Handler from 'asyncstoragehandler'
```
2.Set one of the states in the constructor to be the handler:

```javascript
constructor(){
  super();
  this.state = {
    Handler : new Handler()
  }
}
```

### Complete Example

A complete example on saving data.

```javascript
import React, { Component } from "react";
import { Text, TouchableOpacity, View } from "react-native";
import Handler from "asyncstoragehandler";

export default class HandlerTexter extends Component {
  state = {
    Handler: new Handler()
  };

  _setData = async() => {
    let data = {
      title : "handler test"
    }
    this.state.Handler.setItem('@KEY',data)
    .then((value) => {
      if(value){
        alert("saved");
      }else{
         alert("not saved");
      }
    });
  }

  render() {
    return (
      <View style={{ flex: 1 }}>
        <TouchableOpacity onPress={this._setData}>
          <Text>Save Data</Text>
        </TouchableOpacity>
      </View>
    );
  }
}
```

## Functions and Description

| Functions | Description |
| --- | --- |
| setItem(key: string, value: string) |  Persist a value to asyncStorage for a key. Returns a Promise object |
| setItemArray(key: string, value: string) | Persist an array value to asyncStorage for a key. Returns a Promise object |
| getItem(key: string) |  Gets an item (including array) for a key. Returns a Promise object |
| updateItem(key: string, value: string) |  Updates a value to asyncStorage for a key. Returns a Promise object |
| updateItemArray(key: string, index: integer, value: string) | Update an element from the array value for a key. Returns a Promise object |
| deleteItem(key: string) | Removes an item for a key . Returns a Promise object. |
| deleteItemArray(key: string, index: integer) |  Removes an element from the array value for a key. Returns a Promise object |
| clearAllItem(key: string) | Erases all Item for all clients, libraries, etc. Returns a Promise object. |


## Authors

* **[Musa Joshua](https://github.com/musatech)**

## License

This project is licensed under the MIT License - see the LICENSE.md file for details

## Acknowledgments

* Hat tip to anyone whose code was used directly or indirectly.
* Inspiration
* etc

---
_Source: https://npm.io/package/asyncstoragehandler · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
