For the next step please check our Storm JavaScript Library - Events where you’ll learn about available events for library behaviour.
Learn how to use event-listener system inbuilt into Storm Library for direct communication with your code.
The concept of attaching events is the same as in standard JavaScript.
const storm = stormLibrary(config);
storm.addEventListener("playerReady", onPlayerReady);
In this example, we have added a new event listener (called playerReady) to the library. Whenever the library (player) is ready, an attached function will be called. The function can also be of an inline type.
Now we need to define our function.
function onPlayerReady(event) {
console.log(event.ref); // reference to the library object
};
We can also use inline functions.
storm.addEventListener("playerReady", function(event){
console.log(event.ref); // reference to the library object
});
In order to detach (remove) an event listener just use:
storm.removeEventListener("playerReady", onPlayerReady);
For obvious reasons, inline functions cannot be removed (unless stored as a variable), however, there is a way to remove all events of specific type:
storm.removeEventListener("playerReady");
We can also remove all event listeners from our library element:
storm.removeAllEventListeners();
Create a free ticket and our support team will provide you necessary assistance.