Created
January 3, 2017 23:37
-
-
Save wbamberg/750c26db8a5fd5253d88b08066a7a54b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// background-script.js | |
var responseCallback; | |
function respondAsync() { | |
setTimeout(() => { | |
responseCallback({response: "async response from background script"}); | |
}, 1000); | |
} | |
function handleMessage(request, sender, sendResponse) { | |
console.log(`content script sent a message: ${request.content}`); | |
responseCallback = sendResponse; | |
respondAsync(); | |
return true; | |
} | |
browser.runtime.onMessage.addListener(handleMessage); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment