mirror of
https://github.com/enso-org/enso.git
synced 2024-12-19 05:01:31 +03:00
44f2f425c0
- Depends on #7773. - Implements binary WebSocket protocol (data protocol) - Performs some editor initialization (the bare minimum so that visualizations work) - Adds event handlers to receive visualization data updates # Important Notes None
26 lines
485 B
TypeScript
26 lines
485 B
TypeScript
import { ObservableV2 } from 'lib0/observable'
|
|
|
|
type EventHandler = (...arg0: any[]) => void
|
|
|
|
type EventMap = {
|
|
[key: string]: EventHandler
|
|
}
|
|
|
|
export class EventEmitter extends ObservableV2<EventMap> {
|
|
emit(name: string, ...args: unknown[]): void {
|
|
super.emit(name, args)
|
|
}
|
|
|
|
addListener(name: string, f: EventHandler) {
|
|
this.on(name, f)
|
|
}
|
|
|
|
removeListener(name: string, f: EventHandler) {
|
|
this.off(name, f)
|
|
}
|
|
|
|
removeAllListeners() {
|
|
this.destroy()
|
|
}
|
|
}
|