Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create EventEmitter of a healthy mind #267

Open
tshemsedinov opened this issue Dec 10, 2024 · 3 comments
Open

Create EventEmitter of a healthy mind #267

tshemsedinov opened this issue Dec 10, 2024 · 3 comments
Assignees

Comments

@tshemsedinov
Copy link
Member

tshemsedinov commented Dec 10, 2024

type Listener = (...args: unknown[]) => void;
type EventName = string | symbol;

export class EventEmitter {
  emit(eventName: EventName, ...args: unknown[]): Promise<void>;
  on(eventName: EventName, listener: Listener): void;
  once(eventName: EventName, listener: Listener): void;
  off(eventName: EventName, listener?: Listener): void;
  toPromise(eventName: EventName): Promise<unknown>;
  toIterator(eventName: EventName): Iterator<unknown>;
  clear(eventName?: EventName): void;
  listeners(eventName?: EventName): Listener[];
  listenerCount(eventName?: EventName): number;
  eventNames(): EventName[];
}
tshemsedinov added a commit that referenced this issue Dec 11, 2024
GoodLuckMister added a commit to GoodLuckMister/metautil that referenced this issue Dec 20, 2024
GoodLuckMister added a commit to GoodLuckMister/metautil that referenced this issue Dec 20, 2024
@GoodLuckMister
Copy link

GoodLuckMister commented Dec 20, 2024

Hi ! Could I complete this issue ?

@tshemsedinov
Copy link
Member Author

Yes, this is just a draft, it might be useful, but it needs some work, maybe the contracts are not convenient, maybe the implementation can be optimized, more tests, use cases, docs, etc.

@tshemsedinov
Copy link
Member Author

@GoodLuckMister You can do that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants