Working with WebExtension Events

WebExtensions can react on events by attaching a listener. Consider the onClicked event of the menus API:

async function menuListener(info, tab) {
  ...
  // do something with the info and tab parameters received from the event
}

messenger.menus.onClicked.addListener(menuListener);

Alternative implementation using an anonymous arrow function:

messenger.menus.onClicked.addListener(async (info, tab) => {
  // do something with the info and tab parameters received from the event
      ...
});