Skip to content

Commit

Permalink
Update eventListeners.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
jobisoft committed Dec 1, 2023
1 parent 29a160f commit 63a83d4
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions how-to/eventListeners.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ WebExtensions can react on events by attaching a listener. Consider the :ref:`me
.. code-block:: javascript
async function menuListener(info, tab) {
...
// do something with the info and tab parameters received from the event
// Do something with the info and tab parameters
// received from the event.
}
messenger.menus.onClicked.addListener(menuListener);
Expand All @@ -18,6 +18,23 @@ Alternative implementation using an anonymous arrow function:
.. code-block:: javascript
messenger.menus.onClicked.addListener(async (info, tab) => {
// do something with the info and tab parameters received from the event
...
// Do something with the info and tab parameters
// received from the event.
});
Events with additional parameters
=================================

Some events support additional parameters, for example the :ref:`messages.onNewMailReceived` event.

The additional parameter ``monitorAllFolders`` is the second parameter of the ``addListener``
function, specifying whether to monitor just the standard inbox folders, or all folders.

.. code-block:: javascript
async function listener(folder, messages) {
// Do something with the folder and messages parameters
// received from the event.
}
messenger.messages.onNewMailReceived.addListener(listener, true);

0 comments on commit 63a83d4

Please sign in to comment.