1
source$.switchMap(x => promise(x))
.subscribe(x => console.log(x));

source$.switchMap(x => from(promise(x)))
.subscribe(x => console.log(x));

both the lines of code resolves the promise but can someone really point out what's the different in between these two lines of code ?

Ashwin J
  • 662
  • 7
  • 12
  • identical. but i suggest to be more explicit and add 'from' – Fan Cheung Aug 02 '19 at 07:41
  • 1
    Functionaly the two are identical because RxJS handles Observables and Promises the same way. Promise, from RxJS perspective is just an Observable that emits only one item. – martin Aug 02 '19 at 12:02

0 Answers0