Using Events

An event is an object that allows you to be notified when something interesting happens.

Here’s an example of using the onStopStreaming event to be notified whenever a stream has been stopped:

overwolf.streaming.onStopStreaming.addListener(
    function (value) {
        alert("a stream with id " + value.stream_id + " had stopped");
    }
);

As the example shows, you register for notification using addListener().

Important notes:

  • We’ve seen situations where apps would register (addListener) multiple times on the same event – this caused the event to be triggered multiple times and for unexpected bugs and memory leaks, so please pay extra attention when registering to events.
  • You also have the option of unregistering from an event via the removeListener() function.

Methods

addListener(callback)

Version added: 0.78

Registers a listener to the event. When the event occurs, all of the registered listeners are called.

  • Parameter: callback <function>

    The callback function to call when the event occurs.

removeListener(callback)

Unregister a listener to the event.

  • Parameter: callback <function>

    The callback should be the same function that was passed to addListener() - so this won’t work with anonymous function.