'Javascript (howler js) How to pass child property to parent?
Good day everyone, I'm fairly new to Javascript so please forgive me if this is a stupid question. I've been trying to google this, some say to use super() but I'm getting an error of undefined.
I'm using howlerJS. My goal is not to rewrite the same 'onend' listener/function whenever I instantiate a new Howl.
class ChildHowl extends Howl{
...how can i insert 'onend' prop here?...
}
var myHowl = new ChildHowl({
src: ['audio.wav'],
// how to move this onend to ChildHowl as a default
onend: function() {
console.log('audio ended');
.... some stuff ....
}
});
Thank you everyone in advance. You're understanding and consideration is highly appreciated.
Update: Fixed thank you Fabien Auréjac for the help!
class ChildHowl extends Howl{
constructor(obj) {
let onend=function() {
console.log('audio ended');
};
super({ src:obj.src, onend:onend });
}
}
var myHowl = new ChildHowl({
src: ['audio.wav']
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
