MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / chain

Method chain

src/platform/common/utils/async.ts:161–176  ·  view source on GitHub ↗

* Chain the provided promise after all previous promises have successfully completed. * If the previously chained promises have failed, then this call will fail.

(promise: () => Promise<T>)

Source from the content-addressed store, hash-verified

159 * If the previously chained promises have failed, then this call will fail.
160 */
161 public async chain<T>(promise: () => Promise<T>): Promise<T> {
162 const deferred = createDeferred<T>();
163 const previousPromise = this.currentPromise;
164 this.currentPromise = this.currentPromise.then(async () => {
165 try {
166 const result = await promise();
167 deferred.resolve(result);
168 } catch (ex) {
169 deferred.reject(ex);
170 throw ex;
171 }
172 });
173 // Wait for previous promises to complete.
174 await previousPromise;
175 return deferred.promise;
176 }
177 /**
178 * Chain the provided promise after all previous promises have completed (ignoring errors in previous promises).
179 */

Callers

nothing calls this directly

Calls 3

createDeferredFunction · 0.85
resolveMethod · 0.65
rejectMethod · 0.65

Tested by

no test coverage detected