Add a util cancel Promises #203
camsteffen
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I know I know you can't cancel a Promise. But you can create a Promise that never resolves using the Promise constructor. So my idea is to create a util that effectively cancels a Promise when the component is destroyed. Some people say that
Observable
is strictly better thanPromise
, but I would suggest that it depends on your use case. Sometimes aPromise
does all you need and with less code. This utility would make Promises good enough in even more scenarios. And then you get async/await syntax.Usage example:
Possible implementation:
Beta Was this translation helpful? Give feedback.
All reactions