UNPKG

@aurigma/design-atoms

Version:

Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.

32 lines 1.11 kB
export class ExecutionToken { } class ExecutionTokenImpl extends ExecutionToken { } export class AsyncHelper { static getExecutionToken() { return new ExecutionTokenImpl(); } static executeSingle(token, getTask, getContinueTask = null) { if (!(token instanceof ExecutionTokenImpl)) throw new Error("token must be acquired using method getExecutionToken"); if (token.currentExecutionPromise != null) return token.currentExecutionPromise; token.getContinueTask = getContinueTask; token.currentExecutionPromise = new Promise(async (resolve, reject) => { try { await getTask(); if (token.getContinueTask) await token.getContinueTask(); resolve(); } catch (ex) { reject(ex); } finally { token.currentExecutionPromise = null; } }); return token.currentExecutionPromise; } } //# sourceMappingURL=AsyncHelper.js.map