Skip to content

Commit

Permalink
feat(shell): uix: implement UixEventEmitter
Browse files Browse the repository at this point in the history
  • Loading branch information
ilharp committed Aug 23, 2024
1 parent 92133ce commit 23ace14
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion packages/shell/src/services/uix.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */

import { EventEmitter } from 'node:events'
import { api } from './api'

interface UixEventEmitter {
/**
* 监听某键的获得。
*
* @param key 键。
* @param listener 值的监听器。
*/
on(key: string, listener: (value: string) => void): this

/**
* 等待某键的获得。
* @param key 键。
* @param listener 值的监听器。
*/
once(key: string, listener: (value: string) => void): this

/**
* 通知某键的值已获得。
*
* @param key 键。
* @param value 值。
*/
emit(key: string, value: string): boolean
}

class UixEventEmitter extends EventEmitter {}

const uinRegex = /\d+/

const isUin = (uin: unknown) =>
Expand All @@ -12,7 +41,7 @@ const isUid = (uid: unknown) =>

const isGroup = isUin

export class Uix extends EventEmitter {
export class Uix extends UixEventEmitter {
map: Record<string, string> = {}

isUin = isUin
Expand Down

0 comments on commit 23ace14

Please sign in to comment.