user2381114
user2381114

Reputation: 147

Get primitive value from chrome.storage.local

Basically, there is a stored primitive I would like to set as a value of a jQuery UI Tab setting:

$("#tabs").tabs({
    active: chrome.storage.local.get("idx", function(obj){ 
                console.log(obj["idx"])}); // returns primitive integer I want. 
            }), ...  
}); 

The standard chrome-storage-get protocol is quite convoluted and I am unsure how I can simply set the object property value itself to be the value of active: rather than the object.

active: 3 // chrome.storage.local.get("idx")

Any way to do this?

Upvotes: 0

Views: 95

Answers (1)

rgthree
rgthree

Reputation: 7273

chrome.storage is asynchronous, so your code would look more like this:

chrome.storage.local.get("idx", function(obj) {
  $("#tabs").tabs({
    active: obj.idx  
  });
});

Upvotes: 2

Related Questions