Should I be using toPromise in rxjs6? What does it do?

Viewed 947

I'm having a little trouble reading the rxjs documentation.

As far as I can see, this is the official documentation: https://rxjs-dev.firebaseapp.com/api

In the Observable documenation page under methods it has listed lift() and subscribe(), though later down the page, under examples, there are forEach(), pipe(), and toPromise().

None of those have usage notes - just argument specifiers.

Looking at this page: https://www.learnrxjs.io/operators/utility/topromise.html

We're told:

:warning: toPromise has been deprecated! (RxJS 5.5+)

How I am I meant to be reading this? toPromise was deprecated in 5.5x and continues to be deprecated?

1 Answers

TLDR; I think the documentation is incorrect.

toPromise is not deprecated.

Apparently there was some issue when toPromise was moved to operators and then removed in 5.5 beta.

toPromise was only available in rxjs/operators during a beta of 5.5. It was removed because it doesn't make any sense, it's not an operator, it's a method of subscription that results in a promise. See GH issue

Also there is no deprecation notice in the sources and none in the migration guide. Rxjs team is pretty reliable about deprecation warnings.

I think the documentation at https://www.learnrxjs.io/operators/utility/topromise.html is either wrong or it's referring to toPromise as operator - which has been removed.

Related