advanced
Challenge: a tiny event emitter
Implement this from the stub. Hidden tests grade the behaviour you write, not the comments you leave.
Challenge: A Tiny Event Emitter
export type Listener = (payload: unknown) => void
export class EventEmitter {
on(event: string, listener: Listener): void {
// Your implementation here
}
off(event: string, listener: Listener): void {
// Your implementation here
}
once(event: string, listener: Listener): void {
// Your implementation here
}
emit(event: string, payload?: unknown): boolean {
// Your implementation here
}
}challenge — implement from scratchCtrl+↵ submits · Ctrl+Shift+↵ runsstarter code