##DAAsyncStorage for React Native Beginners
This small library will help begineers in react-native to store data easily in their project. Its just a simple helper file which reduces a lot of boiler plate code.
##Usage
Add the DAAsyncStorage.js
file to your project.
Add
var myDB = require('./DAAsyncStorage');
var myDBInstance = new myDB();
- To store any kind of object
myDB.setTheItem(key,value,function() {
// DO ANY FURTHER OPERATIONS AFTER SAVING
});
For eg.
myDB.setTheItem('username','darkarmy',function() {
// DO ANY FURTHER OPERATIONS AFTER SAVING
});
- To fetch any object just send the key to the function and it will return the value as a callback
myDB.getTheItem(key,function(val) {
// Get value in val
});
For eg.
myDB.getTheItem('username',function(val) {
// Saved username will be returned in val
});
- To delete all key-value pairs that are saved, just call this function with all the keys as an array
myDB.deleteAllItems(keys,function() {
// After deletion
});
For eg.
myDB.deleteAllItems(["username","password"],function() {
// After deletion
});