Skip to main content

JavaScript events overview

In this basic overview we'll discuss javaScript events which fuel various Overwolf's APIs.

If you are familiar with JS events, and you want to learn how to use Overwolf game events, you can skip directly to the how to use Overwolf game events guide.

JS Events Basics

An event is an object that reacts when something interesting to you happens. Here’s an example of using the onStopStreaming event to be notified whenever a stream has stopped:

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

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

danger

We’ve seen situations where apps would register addListener multiple times for the same event – this caused the event to be triggered multiple times and causes unexpected bugs and memory leaks. Please pay attention when registering to events and prevent it.

You can also unregister from an event using the removeListener() function.

addListener(callback)

Version added: 0.78

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

ParameterTypeDescription
callbackfunctionThe callback function to call when the event occurs

removeListener(callback)

Version added: 0.78

Unregister a listener to an event.

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