MCPcopy
hub / github.com/bombshell-dev/clack / emit

Method emit

packages/core/src/prompts/prompt.ts:111–129  ·  view source on GitHub ↗

* Emit an event with data * @param event - The event name * @param data - The data to pass to the callback

(
		event: T,
		...data: Parameters<ClackEvents<TValue>[T]>
	)

Source from the content-addressed store, hash-verified

109 * @param data - The data to pass to the callback
110 */
111 public emit<T extends keyof ClackEvents<TValue>>(
112 event: T,
113 ...data: Parameters<ClackEvents<TValue>[T]>
114 ) {
115 const cbs = this._subscribers.get(event) ?? [];
116 const cleanup: (() => void)[] = [];
117
118 for (const subscriber of cbs) {
119 subscriber.cb(...data);
120
121 if (subscriber.once) {
122 cleanup.push(() => cbs.splice(cbs.indexOf(subscriber), 1));
123 }
124 }
125
126 for (const cb of cleanup) {
127 cb();
128 }
129 }
130
131 public prompt() {
132 return new Promise<TValue | symbol | undefined>((resolve) => {

Callers 15

_setValueMethod · 0.95
_setUserInputMethod · 0.95
onKeypressMethod · 0.95
closeMethod · 0.95
utils.test.tsFile · 0.80
date.test.tsFile · 0.80
password.test.tsFile · 0.80
text.test.tsFile · 0.80
multi-line.test.tsFile · 0.80
select.test.tsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected