MCPcopy
hub / github.com/PowerShell/vscode-powershell / WaitEvent

Function WaitEvent

test/utils.ts:119–131  ·  view source on GitHub ↗
(
    event: vscode.Event<TResult>,
    filter?: (event: TResult) => boolean | undefined,
)

Source from the content-addressed store, hash-verified

117 * @returns A promise that resolves when the specified event is fired with the TResult subject of the event. If a filter is specified, the promise will not resolve until the filter returns true.
118 */
119export function WaitEvent<TResult>(
120 event: vscode.Event<TResult>,
121 filter?: (event: TResult) => boolean | undefined,
122): Promise<TResult> {
123 return new Promise<TResult>((resolve) => {
124 const listener = event((result: TResult) => {
125 if (!filter || filter(result)) {
126 listener.dispose();
127 resolve(result);
128 }
129 });
130 });
131}

Callers 1

Calls 1

disposeMethod · 0.45

Tested by

no test coverage detected