source: trip-planner-front/node_modules/rxjs/src/internal/scheduled/scheduled.ts@ 6a3a178

Last change on this file since 6a3a178 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 { scheduleObservable } from './scheduleObservable';
2import { schedulePromise } from './schedulePromise';
3import { scheduleArray } from './scheduleArray';
4import { scheduleIterable } from './scheduleIterable';
5import { ObservableInput, SchedulerLike, Observable } from 'rxjs';
6import { isInteropObservable } from '../util/isInteropObservable';
7import { isPromise } from '../util/isPromise';
8import { isArrayLike } from '../util/isArrayLike';
9import { isIterable } from '../util/isIterable';
10
11/**
12 * Converts from a common {@link ObservableInput} type to an observable where subscription and emissions
13 * are scheduled on the provided scheduler.
14 *
15 * @see from
16 * @see of
17 *
18 * @param input The observable, array, promise, iterable, etc you would like to schedule
19 * @param scheduler The scheduler to use to schedule the subscription and emissions from
20 * the returned observable.
21 */
22export function scheduled<T>(input: ObservableInput<T>, scheduler: SchedulerLike): Observable<T> {
23 if (input != null) {
24 if (isInteropObservable(input)) {
25 return scheduleObservable(input, scheduler);
26 } else if (isPromise(input)) {
27 return schedulePromise(input, scheduler);
28 } else if (isArrayLike(input)) {
29 return scheduleArray(input, scheduler);
30 } else if (isIterable(input) || typeof input === 'string') {
31 return scheduleIterable(input, scheduler);
32 }
33 }
34
35 throw new TypeError((input !== null && typeof input || input) + ' is not observable');
36}
Note: See TracBrowser for help on using the repository browser.