function func(data) {
var data2 = {'apple', 'pear'};
chrome.storage.local.get("key", function(items) {
// Lots of code here that takes time.
// use "data"
// use "data2"
}
}
1) How do I use "data" and "data2" from inside this callback? I'm just not sure how to pass that data into the callback properly. Do I create a global?
2) It seems like I can use them, but from what I understand, it's async, and I'm afraid func() will end before the callback is called and both data and data2 will go out of scope by that time, making them unusable. What is the proper way of doing this?