MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / waitForEvent

Method waitForEvent

src/test/debug_client_ms.ts:323–343  ·  view source on GitHub ↗
(eventType: string, description?: string, timeout?: number, match?: (event: DebugProtocol.Event) => boolean)

Source from the content-addressed store, hash-verified

321 * The promise will be rejected if a timeout occurs.
322 */
323 public waitForEvent(eventType: string, description?: string, timeout?: number, match?: (event: DebugProtocol.Event) => boolean): Promise<DebugProtocol.Event> {
324 let timeoutHandler: any;
325 const startingTestName = currentTestName;
326
327 return new Promise((resolve, reject) => {
328 const handler = (event: DebugProtocol.Event) => {
329 if (!match || match(event)) {
330 this.removeListener(eventType, handler);
331 clearTimeout(timeoutHandler);
332 resolve(event);
333 }
334 };
335
336 this.on(eventType, handler);
337 if (!this._socket) { // no timeouts if debugging the tests
338 timeoutHandler = setTimeout(() => {
339 reject(new Error(`no event '${eventType}' received after ${timeout || this.defaultTimeout} ms (${startingTestName}: ${description})`));
340 }, timeout || this.defaultTimeout);
341 }
342 });
343 }
344
345 /*
346 * Returns a promise that will resolve if an 'initialized' event was received within some specified time

Callers 15

configurationSequenceMethod · 0.95
waitForStopMethod · 0.95
hitBreakpointMethod · 0.95
launchMethod · 0.80
waitAllThrowIfTerminatesFunction · 0.80
dart_test.test.tsFile · 0.80
runTestsFunction · 0.80
runWithoutDebuggingFunction · 0.80
dart_cli.test.tsFile · 0.80
testBreakpointConditionFunction · 0.80

Calls 1

onMethod · 0.80

Tested by 4

runTestsFunction · 0.64
runWithoutDebuggingFunction · 0.64
testBreakpointConditionFunction · 0.64
testBreakpointConditionFunction · 0.64