10 examples of 'javascript wait for callback' in JavaScript

Every line of 'javascript wait for callback' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
49function waitsFor(callback) {
50 if (skipRunsCounter === 0) {
51 jasmineApi.waitsFor.apply(this, arguments);
52 }
53}
41function waitForElement(selector, callback) {
42 if (document.querySelector(selector)) {
43 return callback()
44 } else {
45 setTimeout(waitForElement.bind(this, selector, callback), 300)
46 }
47}
250function Wait(callback) {
251 if (!suite.isPlayback) {
252 setTimeout(function () {
253 //console.log('sleep for 30 seconds');
254 return callback(null);
255 }, 30000);
256 } else {
257 return callback(null);
258 }
259}
42function _waitForCallback(callback) {
43 var id = _generateCallbackID();
44
45 function listener(event) {
46 if (typeof event.detail != 'object')
47 return;
48 if (event.detail.callbackID != id)
49 return;
50
51 document.removeEventListener('mozUITourResponse', listener);
52 callback(event.detail.data);
53 }
54 document.addEventListener('mozUITourResponse', listener);
55
56 return id;
57}
190.waitForElementNotPresent({ selector: '.nock-object', timeout: 50, retryInterval: 20, abortOnFailure: false }, function callback(result) {
191 assert.equal(result.status, 0, 'waitForElementNotPresent "succeeds"');
192 assert.equal(result.value.length, 3, 'waitForElementNotPresent returns the found elements');
193});
84export function waitFor(timeout, done, onCallback, onTimeout) {
85 if (typeof onCallback !== 'function') {
86 onCallback = onCallback
87 ? function (r) { void expect(r).to.be.exist; }
88 : function (r) { expect.fail('unexpected callback: ' + r); };
89 }
90 if (typeof onTimeout !== 'function') {
91 onTimeout = onTimeout
92 ? function () {}
93 : function () { expect.fail('timeout'); };
94 }
95 let to = setTimeout(() => {
96 try {
97 to = null;
98 onTimeout();
99 } catch (e) {
100 return done(e);
101 }
102 return done();
103 }, timeout);
104 return function () {
105 if (to == null) return;
106 try {
107 clearTimeout(to);
108 to = null;
109 onCallback.apply(this, arguments);
110 } catch (e) {
111 return done(e);
112 }
113 return done();
114 };
115}
209function waitForElement(selector, callback) {
210 waitFor(function() {
211 return !!$(selector).length;
212 }, callback);
213}
21waitFor(callback:Function):Promise {
22 throw new BaseException('NYI');
23}
7function wait() {
8 var meta = document.getElementById('d41d8cd98f00b204e9800998ecf8427e_lib_detect');
9 if (meta) {
10 chrome.extension.sendMessage(meta.content);
11 }
12}
66(function wait() { setTimeout(wait, 5000) })();

Related snippets