Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(asyncScheduler): document asyncScheduler's known limitation #7213

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/internal/observable/timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ import { isValidDate } from '../util/isDate';
*
* ### Known Limitations
*
* - The {@link asyncScheduler} uses `setTimeout` which has limitations for how far in the future it can be scheduled.
* - The {@link asyncScheduler} uses [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout)
* internally which has limitation for how far in the future it can be scheduled. The `delay` used by `setTimeout`
* uses 32-bit signed integer internally. This causes an integer overflow when using delays larger than 2,147,483,647
* ms (about 24.8 days), [resulting in the timeout being executed
* immediately](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#maximum_delay_value).
*
* - If a `scheduler` is provided that returns a timestamp other than an epoch from `now()`, and
* a `Date` object is passed to the `dueTime` argument, the calculation for when the first emission
Expand Down
14 changes: 10 additions & 4 deletions src/internal/scheduler/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { AsyncAction } from './AsyncAction';
import { AsyncScheduler } from './AsyncScheduler';

/**
* An asynchronous scheduler that schedules tasks on the JavaScript event loop queue.
*
* Async Scheduler
*
* <span class="informal">Schedule task as if you used setTimeout(task, duration)</span>
* <span class="informal">Schedules a task as if you used `setTimeout(task, duration)`.</span>
*
* `asyncScheduler` scheduler schedules tasks asynchronously, by putting them on the JavaScript
* event loop queue. It is best used to delay tasks in time or to schedule tasks repeating
Expand Down Expand Up @@ -46,6 +45,13 @@ import { AsyncScheduler } from './AsyncScheduler';
* // 2 after 5s
* // 3 after 6s
* ```
*
* ### Known Limitation
*
* The {@link asyncScheduler} uses [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout)
* internally which has limitation for how far in the future it can be scheduled. The `delay` used by `setTimeout`
* uses 32-bit signed integer internally. This causes an integer overflow when using delays larger than 2,147,483,647
* ms (about 24.8 days), [resulting in the timeout being executed
* immediately](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#maximum_delay_value).
*/

export const asyncScheduler = new AsyncScheduler(AsyncAction);