title: Rxjs 6 flatten observable
body: <p>I need your advice on how to convert the Rxjs 5 to Rxjs 6.</p>
  
  <p>My code is below and I am not too sure why it did not work.</p>
  
  <p>Rxjs 5</p>
  
  <pre><code>Observable.from([{amount:5},{amount:10}])
  .flatMap(_ =&gt; depositService.deposit(depositAmount))
  .toArray()
  .subscribe(result =&gt; {
      console.log(result.length);
  })
  </code></pre>
  
  <p>Rxjs 6</p>
  
  <pre><code>import { Observable, from, } from 'rxjs';
  import { map, catchError, mergeMap} from 'rxjs/operators';
  ...
  
  const source = from([{amount:5},{amount:10}]);
  source
  .pipe(mergeMap(_ =&gt; depositService.deposit(_.amount).toArray())
  .subscribe(result =&gt; {
      console.log(result.length);
  })
  </code></pre>
  
  <p>I got the error </p>
  
  <p>You provided an invalid object where a stream was expected You can provide an Observable, Promise, Array, or Iterable.</p>