Skip to main content
Module

x/tui/mod.ts>EventEmitter

🦕 Deno module for creating Terminal User Interfaces
Go to Latest
class EventEmitter
Re-export
import { EventEmitter } from "https://deno.land/x/tui@2.1.5/mod.ts";

Custom implementation of event emitter

Properties

listeners: [key in keyof EventMap]?: EventListener<EventMap, key>[]

Methods

emit<Type extends keyof EventMap>(type: Type, ...args: EventMap[Type]["args"]): void

Emit specific type, after emitting all listeners associated with that event type will run with given arguments

off(): void

Remove event listeners

  • If no event type is passed, every single listener will be removed
  • If just type is passed with no listener, every listener for specific type will be removed
  • If both type and listener is passed, just this specific listener will be removed
off<Type extends keyof EventMap>(type: Type): void
off<Type extends keyof EventMap>(type: Type, listener: EventListener<EventMap, Type>): void
on<Type extends keyof EventMap>(
type: Type,
listener: EventListener<EventMap, Type>,
once?: boolean,
): () => void

Add new listener for specified event type If once is set to true it will run just once and then be removed from listeners list