I have the following code:
class classA {
constructor() {
createjs.EventDispatcher.initialize(classA.prototype);
this.addEventListener("someEvent", function(evt) {
console.log("classA has detected something has happened!");
});
}
}
class classB {
constructor() {
createjs.EventDispatcher.initialize(classB.prototype);
this.addEventListener("someEvent", function(evt) {
console.log("classB has detected something has happened!");
});
this.dispatchEvent("someEvent");
}
}
let a = new classA();
let b = new classB();
Now when I construct classA it is set to listen for "someEvent", however when "someEvent" is dispatched in the constructor of classB only classB registers the event.
Why is this?