1 import { scheduleObservable } from './scheduleObservable';
2 import { schedulePromise } from './schedulePromise';
3 import { scheduleArray } from './scheduleArray';
4 import { scheduleIterable } from './scheduleIterable';
5 import { ObservableInput, SchedulerLike, Observable } from 'rxjs';
6 import { isInteropObservable } from '../util/isInteropObservable';
7 import { isPromise } from '../util/isPromise';
8 import { isArrayLike } from '../util/isArrayLike';
9 import { isIterable } from '../util/isIterable';
12 * Converts from a common {@link ObservableInput} type to an observable where subscription and emissions
13 * are scheduled on the provided scheduler.
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.
22 export function scheduled<T>(input: ObservableInput<T>, scheduler: SchedulerLike): Observable<T> {
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);
35 throw new TypeError((input !== null && typeof input || input) + ' is not observable');