Skip to content

Instantly share code, notes, and snippets.

@ayberkanilatsiz
Created August 3, 2017 13:45
Show Gist options
  • Save ayberkanilatsiz/3da1d17adaa33ebe81bb9d1cc014e0c9 to your computer and use it in GitHub Desktop.
Save ayberkanilatsiz/3da1d17adaa33ebe81bb9d1cc014e0c9 to your computer and use it in GitHub Desktop.
createNewKey(name,backgroundColor){
return new Promise((resolve,reject)=>{
this.getItems().then((data)=>{
let tempKey = new Date().getTime();
data[tempKey] = {
name, //Count Name
count:0,
backgroundColor, // Count Background Color
counts:[] // counts
};
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