Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yeah, this is an important question. I don't have answer for you and neither do the people in charge of the fetch API. It's an issue with promises not being cancelable. There's probably a reasonable argument that promises just aren't that great because you can only resolve or reject.

Personally I don't see a huge problem with either resolving or rejecting with a message about the cause of the result. Others see it differently but they haven't been able to make any progress on a major problem.

If you want to avoid this altogether there's no reason why you can't use a different library.



What about using observables? Unlike promises, they can be cancelled at any time.

Rxjs provides the observable data type. The extensions are functional reactive operators. There are operators used to retry, throttle, filter, debounce, etc.

Angular2's http module is already based on Rxjs observables for this exact reason.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: