Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make fromPromise support promise cancellation? #2652

Closed
felixfbecker opened this issue Jun 10, 2017 · 4 comments
Closed

Make fromPromise support promise cancellation? #2652

felixfbecker opened this issue Jun 10, 2017 · 4 comments

Comments

@felixfbecker
Copy link
Contributor

felixfbecker commented Jun 10, 2017

Many non-standard promise implementations support a promise.cancel() method that cancels the promise:

  • WinJS (used in Visual Studio Code)
  • Angular 1 ($timeout has cancel())
  • Bluebird (if enabled)

The only way to currently convert these to Observables is to write by hand:

return new Observable(subscriber => {
  const promise = foo();
  Observable.fromPromise(promise).subscribe(subscriber);
  return () => promise.cancel();
})

Would there be any downside to have PromiseObservable check if the promise has a cancel method, and if present, invoke it on unsubscription?

@staltz
Copy link
Member

staltz commented Jun 14, 2017

I think this is a good idea to consider.

@MychaelZ
Copy link

How is this not supported?

@felixfbecker
Copy link
Contributor Author

felixfbecker commented Sep 9, 2019

I have since changed my opinion on this. The standard way to cancel Promises in JS is AbortSignal now. Angular 1, WinJS and Bluebird are rarely used anymore.

@kwonoj
Copy link
Member

kwonoj commented Jan 22, 2021

Closing as core team trying to follow spec complaint abortsignal.

@kwonoj kwonoj closed this as completed Jan 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants