mirror of
https://github.com/woodchen-ink/clash-and-dashboard.git
synced 2025-07-18 14:01:56 +08:00
24 lines
500 B
TypeScript
24 lines
500 B
TypeScript
import * as EventEmitter from 'eventemitter3'
|
|
|
|
export enum Action {
|
|
SPEED_NOTIFY = 'speed-notify'
|
|
}
|
|
|
|
class Event {
|
|
protected EE = new EventEmitter()
|
|
|
|
notifySpeedTest () {
|
|
this.EE.emit(Action.SPEED_NOTIFY)
|
|
}
|
|
|
|
subscribe<T> (event: Action, callback: (data?: T) => void) {
|
|
this.EE.addListener(event, callback)
|
|
}
|
|
|
|
unsubscribe<T> (event: Action, callback: (data?: T) => void) {
|
|
this.EE.removeListener(event, callback)
|
|
}
|
|
}
|
|
|
|
export default new Event()
|