'Create custom (this.on) events from event window.addEventListener
I'm trying to intercept some window.addEventListener inside custom "this.on events".
I am trying with this code, I have no idea how to get my result :(
(i receive correctly the window.addEventListener)
Anyone have any ideas?
Function
function playersdk(...){
window.addEventListener('message', ({ data }) => {
let eventData = JSON.parse(data);
this.on = function (event, obj) {
console.log(eventData);
if (event == eventData.type) {
return eventData;
}
}
});
}
main page
let player=new playersdk();
player.on('play', e => console.log('play'));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
