Last active
August 3, 2017 13:52
-
-
Save ayberkanilatsiz/a1d48be4264c4746961664d83b2d96cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setItemWithKey(key,obj){ | |
return new Promise((resolve,reject)=>{ | |
// count object example | |
// obj = { | |
// action : 1 || 0, | |
// time, | |
// } | |
this.getItems().then((data)=>{ | |
if(obj.action === 1){ | |
data[key].count++; | |
}else{ | |
data[key].count--; | |
} | |
data[key].counts.push(obj); | |
AsyncStorage.setItem('count', JSON.stringify(data), (err,result) => { | |
if(err){ | |
reject({err:'something went wrong!'}); | |
}else{ | |
resolve(true); | |
} | |
}); | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment