@dxos/async
Advanced tools
Comparing version 2.18.1 to 2.18.2
@@ -97,2 +97,6 @@ export declare type Effect = () => (() => void) | undefined; | ||
/** | ||
* Similar to waitFor, but the promise resolves immediatelly if the condition is already true. | ||
*/ | ||
waitForCondition(predicate: () => boolean): Promise<void>; | ||
/** | ||
* Returns the number of persistent listeners. | ||
@@ -99,0 +103,0 @@ */ |
@@ -163,2 +163,10 @@ "use strict"; | ||
/** | ||
* Similar to waitFor, but the promise resolves immediatelly if the condition is already true. | ||
*/ | ||
async waitForCondition(predicate) { | ||
if (!predicate()) { | ||
await this.waitFor(predicate); | ||
} | ||
} | ||
/** | ||
* Returns the number of persistent listeners. | ||
@@ -228,4 +236,9 @@ */ | ||
async _trigger(listener, data) { | ||
await waitImmediate(); // Acts like setImmediate but preserves the stack-trace. | ||
listener(data); | ||
try { | ||
await waitImmediate(); // Acts like setImmediate but preserves the stack-trace. | ||
listener(data); | ||
} | ||
catch (err) { | ||
console.error(err); | ||
} | ||
} | ||
@@ -232,0 +245,0 @@ _runEffects() { |
{ | ||
"name": "@dxos/async", | ||
"version": "2.18.1", | ||
"version": "2.18.2", | ||
"description": "Async utils.", | ||
@@ -27,6 +27,6 @@ "bugs": { | ||
"dependencies": { | ||
"@dxos/debug": "2.18.1" | ||
"@dxos/debug": "2.18.2" | ||
}, | ||
"devDependencies": { | ||
"@dxos/toolchain-node-library": "2.18.1", | ||
"@dxos/toolchain-node-library": "2.18.2", | ||
"@types/jest": "^26.0.7", | ||
@@ -33,0 +33,0 @@ "@types/node": "^14.0.9" |
@@ -194,2 +194,11 @@ // | ||
/** | ||
* Similar to waitFor, but the promise resolves immediatelly if the condition is already true. | ||
*/ | ||
async waitForCondition (predicate: () => boolean): Promise<void> { | ||
if (!predicate()) { | ||
await this.waitFor(predicate); | ||
} | ||
} | ||
/** | ||
* Returns the number of persistent listeners. | ||
@@ -268,4 +277,8 @@ */ | ||
private async _trigger (listener: (data: T) => void, data: T) { | ||
await waitImmediate(); // Acts like setImmediate but preserves the stack-trace. | ||
listener(data); | ||
try { | ||
await waitImmediate(); // Acts like setImmediate but preserves the stack-trace. | ||
listener(data); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
} | ||
@@ -272,0 +285,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
121854
2164
+ Added@dxos/debug@2.18.2(transitive)
- Removed@dxos/debug@2.18.1(transitive)
Updated@dxos/debug@2.18.2