The above code is correct and passes the context correctly to eventemitter3, but typescript complains about the 'this'. Is this a mistake?
Should for example:
on<E extends keyof Events> (event: E, listener: Events[E]): this
instead be:
on<E extends keyof Events> (event: E, listener: Events[E], context?: any): this
This is great for providing typed events, however, there doesn't seem to be any allowance for the optional context that can be passed to an event.
PlayBus.on('botDestroyed', this.attemptSpawn, this)
The above code is correct and passes the context correctly to eventemitter3, but typescript complains about the 'this'. Is this a mistake? Should for example:
on<E extends keyof Events> (event: E, listener: Events[E]): this
instead be:
on<E extends keyof Events> (event: E, listener: Events[E], context?: any): this