Add async function version of message listener example.

This commit is contained in:
Kris Maglione 2016-10-10 14:02:56 -07:00
parent 0007c27bb9
commit 2dd404db0f
1 changed files with 13 additions and 0 deletions

View File

@ -158,4 +158,17 @@ browser.runtime.onMessage.addListener(msg => {
}); });
``` ```
or:
```javascript
browser.runtime.onMessage.addListener(async function(msg) {
if (msg == "get-ids") {
let {idPattern} = await browser.storage.get("idPattern");
return Array.from(document.querySelectorAll(idPattern),
elem => elem.textContent);
}
});
```
Or vice versa. Or vice versa.