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

fromIterable.ts 511B

123456789101112131415
  1. import { Observable } from '../Observable';
  2. import { SchedulerLike } from '../types';
  3. import { subscribeToIterable } from '../util/subscribeToIterable';
  4. import { scheduleIterable } from '../scheduled/scheduleIterable';
  5. export function fromIterable<T>(input: Iterable<T>, scheduler?: SchedulerLike) {
  6. if (!input) {
  7. throw new Error('Iterable cannot be null');
  8. }
  9. if (!scheduler) {
  10. return new Observable<T>(subscribeToIterable(input));
  11. } else {
  12. return scheduleIterable(input, scheduler);
  13. }
  14. }