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