ray-rn-storage
v1.0.2
Published
amos rn net module
Downloads
5
Readme
ray-rn-storage
author
ilex.h
dependencies:
- "react-native": "^0.48.1"
useage
import Store from 'ray-rn-storage';
// normal
Store.getItem('token').then(value => value);
// async/await
async function getAuthData(){
const token = await Store.getItem('token');
return token;
}
apis
|name|params|return|description|
|------|------|------|------|
| getItem | (key: string, cb?: Callback
)|Promise|根据key获取数据|
| setItem |(key: string, value: string, cb?: Callback
)|Promise|设置key-value|
| removeItem |(key: string, cb?: Callback
)|Promise|移除数据|
| getAllKeys |(cb?: Callback
)|Promise|获取所有的key|
| clear |-|Promise|清除所有|
| multiGet | (keys: Array<string>
)|Promise<Array<[string, ?string]>>
|获取多个数据|
| mergeItem | (key: string
)|Promise|合并建数据|
| flushGetRequests | - | void |--|
| multiSet | (kvPairs: Array<[string, string]>
)|Promise|批量设置|
| multiRemove | (keys: Array<string>
)|Promise|批量删除|
| multiMerge | (kvPairs: Array<[string, string]>
)|Promise|批量合并|
rstore
a wrapper around RN's AsyncStorage
use
import RStore from 'ray-rn-storage/lib/rstore';
RStore.get('token').then(v => v);
RStore.get(['token', 'apikey']).then(v => v);
...
apis
|name|params|return|description|
|------|------|------|------|
| get | (key: String | Array
)|Promise|Get a one or more value for a key or array of keys from AsyncStorage|
| save | (key: String | Array, value: Any
)|Promise|Save a key value pair or a series of key value pairs to AsyncStorage.|
| update | (key: String, value: Any
)|Promise|Updates the value in the store for a given key in AsyncStorage. If the value is a string it will be replaced. If the value is an object it will be deep merged.|
| delete | (key: String | Array
)|Promise|Delete the value for a given key in AsyncStorage.|
| keys | -- |Promise|Get all keys in AsyncStorage|
| push | (key: String, value: Any
) |Promise|Push a value onto an array stored in AsyncStorage by key or create a new array in AsyncStorage for a key if it's not yet defined.|
License
MIT