Alternative to toPromise with downgradeInjectable

56 views Asked by At

A service I've written in Angular is being consumed in a third party angularJS application. My pattern has been: create a service method which returns Observable<someType> and then create a wrapper for that method returning a Promise<someType>. e.g.

getDetails(a: string, b: number) : Observable<IMyType> { ... }
getDetailsPromise(a: string, b: number) : Promise<IMyType> { 
  return this.getDetails(a, b).toPromise(); 
}

The service is then used in the 3rd party AngularJS application using downgradeInjectable and the angularJS code uses the "Promise" version of the service functions.

As toPromise is being deprecated in RxJS 8, what is the alternative to continue allowing the angularJS application to access async Service functions from the Angular Library?

0

There are 0 answers