Accessing a public method in a listener's class
Hi, I currently have a public method on my listener that i want to access from another listener, below is an example of my current code:
my goal here is to call
resetInterval()
from another listener, but i currently have no idea how to call it without calling new
on the listener above.Solution:Jump to solution
Seeing you use TypeScript, you can do this instead:```ts
import type { UserEvent as TimerUserEvent } from './event-name.js';
export class UserEvent extends Listener {
......
2 Replies
Solution
Seeing you use TypeScript, you can do this instead:
That being said, pieces are supposed to be independent, so I would recommend you have a shared file for the two listeners and call from there rather than having a listener call another listener, it'll also solve casting and naming issues.
thanks, guess i overdid myself again 😅