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

Method waitForCustomEvent

src/test/dart_debug_client.ts:322–345  ·  view source on GitHub ↗
(type: string, filter?: (notification: T) => boolean)

Source from the content-addressed store, hash-verified

320 }
321
322 public waitForCustomEvent<T>(type: string, filter?: (notification: T) => boolean): Promise<T> {
323 return new Promise((resolve, reject) => {
324 setTimeout(
325 () => {
326 reject(new Error(`No customEvent '${type}' matching ${filter} received after ${this.defaultTimeout} ms`));
327 },
328 this.defaultTimeout,
329 );
330 const handler = (event: DebugProtocol.Event) => {
331 try {
332 const notification = event.body as T;
333 if (!filter || filter(notification)) {
334 this.removeListener(type, handler);
335 resolve(notification);
336 }
337 } catch (e) {
338 this.removeListener(type, handler);
339 reject(e);
340 }
341 };
342 this.on(type, handler);
343 this.on("terminated", () => this.removeListener(type, handler));
344 });
345 }
346
347 public async waitForTestNotification<T extends Notification>(type: string, filter: (notification: T) => boolean): Promise<void> {
348 await this.waitForCustomEvent<T>(

Callers 4

debuggerReadyMethod · 0.95
flutterAppStartedMethod · 0.95
dart_cli.test.tsFile · 0.80

Calls 1

onMethod · 0.80

Tested by

no test coverage detected