Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

scheduled.ts 1.5KB

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