source: trip-planner-front/node_modules/rxjs/src/internal/scheduler/async.ts@ 6fe77af

Last change on this file since 6fe77af was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.5 KB
Line 
1import { AsyncAction } from './AsyncAction';
2import { AsyncScheduler } from './AsyncScheduler';
3
4/**
5 *
6 * Async Scheduler
7 *
8 * <span class="informal">Schedule task as if you used setTimeout(task, duration)</span>
9 *
10 * `async` scheduler schedules tasks asynchronously, by putting them on the JavaScript
11 * event loop queue. It is best used to delay tasks in time or to schedule tasks repeating
12 * in intervals.
13 *
14 * If you just want to "defer" task, that is to perform it right after currently
15 * executing synchronous code ends (commonly achieved by `setTimeout(deferredTask, 0)`),
16 * better choice will be the {@link asapScheduler} scheduler.
17 *
18 * ## Examples
19 * Use async scheduler to delay task
20 * ```ts
21 * import { asyncScheduler } from 'rxjs';
22 *
23 * const task = () => console.log('it works!');
24 *
25 * asyncScheduler.schedule(task, 2000);
26 *
27 * // After 2 seconds logs:
28 * // "it works!"
29 * ```
30 *
31 * Use async scheduler to repeat task in intervals
32 * ```ts
33 * import { asyncScheduler } from 'rxjs';
34 *
35 * function task(state) {
36 * console.log(state);
37 * this.schedule(state + 1, 1000); // `this` references currently executing Action,
38 * // which we reschedule with new state and delay
39 * }
40 *
41 * asyncScheduler.schedule(task, 3000, 0);
42 *
43 * // Logs:
44 * // 0 after 3s
45 * // 1 after 4s
46 * // 2 after 5s
47 * // 3 after 6s
48 * ```
49 */
50export const asyncScheduler = new AsyncScheduler(AsyncAction);
51
52/**
53 * @deprecated renamed. Use {@link asyncScheduler}
54 */
55export const async = asyncScheduler;
Note: See TracBrowser for help on using the repository browser.