You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ The package is available on [npm](https://npmjs.org/package/async-wait-until):
20
20
$ npm install --save async-wait-until
21
21
```
22
22
23
-
It ships with a[UMD](https://github.com/umdjs/umd) bundle by default (which works well as-is on Node.js and web browsers), but bundles for other module systems are also available in the package's `dist/` folder.
23
+
It ships with an[UMD](https://github.com/umdjs/umd) bundle by default (which works well as-is on Node.js and web browsers), but bundles for other module systems are also available in the package's `dist/` folder.
However, we aren't 100% sure that the `<div />` will be added within 10 seconds. What will happen if 10 seconds have passed and the `<div />` node still isn't there?
173
173
174
-
From the above code, it's clear that our `'predicate'` function (or simply `'preddcate'`) won't return the DOM node. So what `waitUntil` will do in that case is it will throw a `TimeoutException` (also exported from the library so you can handle it).
174
+
From the above code, it's clear that our `'predicate'` function (or simply `'predicate'`) won't return the DOM node. So what `waitUntil` will do in that case is it will throw a `TimeoutException` (also exported from the library so you can handle it).
// Unfortunately, 10 seconds have passed but we haven't detected the `<div />`
193
-
// If we had a UI, we could show an error there or allow user to retry
193
+
// If we had a UI, we could show an error there or allow the user to retry
194
194
alert('No <div /> have been detected unfortunately');
195
195
} else {
196
-
// Some another error, most likely thrown from the predicate function.
196
+
// Some other error, most likely thrown from the predicate function.
197
197
alert('Unknown error occurred');
198
198
console.error(e);
199
199
}
@@ -205,15 +205,15 @@ So, summing up the above, the predicate will run again and again within the give
205
205
206
206
### API
207
207
208
-
Lets' start with the `waitUntil` function. It takes up to two parameters (**deprecated**: up to three), and returns a Promise that will be resolved with the first non-falsy value returned by the predicate.
208
+
Let's start with the `waitUntil` function. It takes up to two parameters (**deprecated**: up to three), and returns a Promise that will be resolved with the first non-falsy value returned by the predicate.
209
209
210
210
Parameter | Type | Required | Default | Description
`predicate` | Function | ✅ Yes | - | A function that is expected to return a non-falsy (aka a `'truthy'`) value, or a Promise to return such a value. Hence, *both sync and async functions are supported*.
213
213
`options` | Options object | 🚫 No | 5000 ms | Options for the wait algorithm implemented by `waitUntil`, see its properties on the below table. **Deprecated**: timeout in milliseconds.
214
214
~~intervalBetweenAttempts~~ | number | 🚫 No | 50 ms | **Deprecated parameter**: number of milliseconds between retry attempts. Please use options instead.
215
215
216
-
Above, you could see the options param. Here are the available **options**:
216
+
Above, you can see the options param. Here are the available **options**:
217
217
218
218
Parameter | Type | Required | Default | Description
If you aren't sure how long with a process take, you can use `waitUntil.Forever` (which is a shortcut for [Number.POSITIVE_INFINITY](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY)) as the timeout value:
227
+
If you aren't sure how long a process will take, you can use `waitUntil.Forever` (which is a shortcut for [Number.POSITIVE_INFINITY](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY)) as the timeout value:
0 commit comments