I'm learning to code Chrome Extensions and I'm curious about passing parameters into asynchronous functions and a possible concurrency issue. Let me give you an example:
function updateActiveTab(param1)
{
chrome.tabs.query({active: true, currentWindow: true}, function(tabs)
{
onUpdatingTab(tabs[0].id, param1);
});
}
function onUpdatingTab(tabID, param1)
{
console.log("Tag ID=" + tabID + ", param=" + param1);
}
So, lets assume that the first time my updateActiveTab() method is called with param1=1 and the call to chrome.tabs.query() takes a while. In the meantime, while chrome.tabs.query() is still being processed, my updateActiveTab() method is called again with param1=2. What would happen when the first call to chrome.tabs.query() returns and begins processing its callback function? Will param1 be 1 or 2?
I'm obviously looking to pass my param1 as 1, and 2, and so on, to its function's respective calls.