RxJS version: 5.0.1
Code to reproduce: https://jsfiddle.net/tossp/nmf9jg32/
toPromise is essentially observable.last().subscribe()
If you add .take(1) just before you call toPromise then things will start to work.
ie
example.do((value)=>console.log('do!!!',value)).take(1).toPromise()
Thank you so much
I just spend 3 hours fighting toPromise returning _nothing_ and wondering why until I found this issue.
This behaviour was not obvious (to me) when reading the RxJs docs. Still trying to wrap my head around why take(1) solved it for me as well.
@cjk toPromise will never resolve until the observable it is sourced from calls complete. So if you bind to a keyboard event Observable.fromEvent(document, 'onload'), that observable will never complete, unless you force it to through something like take(1).
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
toPromiseis essentiallyobservable.last().subscribe()If you add
.take(1)just before you calltoPromisethen things will start to work.ie
example.do((value)=>console.log('do!!!',value)).take(1).toPromise()