title: What is the difference between using 'from' and 'of' when using switchMap?
body: <p>This is my TS code using RxJS:</p>
  
  <pre><code>function getParam(val:any):Observable&lt;any&gt; {
          return from(val).pipe(delay(1000))
      }
  
      of(1,2,3,4).pipe(
          switchMap(val =&gt; getParam(val))
      ).subscribe(val =&gt; console.log(val));
  </code></pre>
  
  <p>My understanding of the getParam function is, it will return 'val' wrapped in an observable. However, switchMap throws the following error:</p>
  
  <pre><code>hostReportError.js:5 Uncaught TypeError: You provided '1' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
      at subscribeTo (subscribeTo.js:39)
      at Module.from (from.js:15)
      at getParam (index.ts:6)
      at SwitchMapSubscriber.eval [as project] (index.ts:8)
      at SwitchMapSubscriber._next (switchMap.js:43)
      at SwitchMapSubscriber.Subscriber.next (Subscriber.js:63)
      at Observable.eval [as _subscribe] (subscribeToArray.js:7)
      at Observable._trySubscribe (Observable.js:50)
      at Observable.subscribe (Observable.js:36)
      at SwitchMapOperator.call (switchMap.js:27)
  </code></pre>
  
  <p>If I change the code of getParam to:</p>
  
  <pre><code>function getParam(val:any):Observable&lt;any&gt; {
      return of(val).pipe(delay(1000))
  }
  </code></pre>
  
  <p>It returns <code>4</code> as expected. So why isn't <code>from</code> operator returning an observable in this case?</p>
  
  <p>Edit: This is not a duplicate of <a href="https://stackoverflow.com/questions/42704552/rxjs-observable-of-vs-from">RxJs Observable of vs from</a> because I am not asking about the input arguments for <code>from</code> and <code>of</code>. My question is both <code>from</code> and <code>of</code> should both observables, yes? But when I use <code>from</code>, <code>switchMap</code> complains that it is NOT receiving an observable and it is just getting '1' from the array. Hope this clarifies.</p>