Skip to content

Instantly share code, notes, and snippets.

@trickidicki
Last active September 19, 2018 01:42
Show Gist options
  • Save trickidicki/dcf1bed40112648cbff9d3f849c52da5 to your computer and use it in GitHub Desktop.
Save trickidicki/dcf1bed40112648cbff9d3f849c52da5 to your computer and use it in GitHub Desktop.
Using Promise/resolve for chrome storage
function getSetting(setting) {
return new Promise(resolve => {
chrome.storage.sync.get(setting, result => {
resolve(result[setting]);
})
});
}
getSetting('MySetting').then(setting => {
console.log("Setting is: " + setting)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment