MCPcopy Index your code
hub / github.com/mailvelope/mailvelope / waitForEvent

Method waitForEvent

test/integration/__mocks__/chrome-api-setup.js:197–214  ·  view source on GitHub ↗

* Wait for a specific event to be captured * @param {string} eventType - The event type to wait for * @param {number} timeout - Timeout in milliseconds (default: 5000) * @returns {Promise} Promise that resolves with the event when found

(eventType, timeout = 5000)

Source from the content-addressed store, hash-verified

195 * @returns {Promise} Promise that resolves with the event when found
196 */
197 waitForEvent(eventType, timeout = 5000) {
198 return new Promise((resolve, reject) => {
199 const timeoutId = setTimeout(() => {
200 reject(new Error(`Timeout waiting for event: ${eventType}`));
201 }, timeout);
202
203 const checkEvent = () => {
204 const event = this._capturedEvents.find(e => e.event === eventType);
205 if (event) {
206 clearTimeout(timeoutId);
207 resolve(event);
208 } else {
209 setTimeout(checkEvent, 10);
210 }
211 };
212 checkEvent();
213 });
214 }
215
216 /**
217 * Static method to create a connection

Callers 4

setupEditorFunction · 0.80

Calls

no outgoing calls

Tested by 2

setupEditorFunction · 0.64