I have a chrome-extension with lots lines of code. More and more people demand that I offer that extension on other browsers (like firefox), too.
Because it is a chrome extension, a lot of chrome-specific functions are included. As I start I want to put all chrome-specific methods in a javascript-file "chrome.js" and encapsulate the chrome-functions with my own so I could easily create other browser-specific methods.
This is quite easy for simple methods:
function geti18nMessage(messageId) {
return chrome.i18n.getMessage(messageId)
}
But how can I encapsulate (asynchronous) methods that return a function?
Example:
chrome.runtime.sendMessage(
{
Action: "Load"
}, function (response)
{
console.log("response is "+response);
});
This isn't really chrome-specific, but the chrome-issue is a real-world-example for my problem.
sendMessagemethod has?