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 Reader Cancelable/Abortable #131

Open
toastal opened this issue Jul 5, 2020 · 2 comments
Open

Make Reader Cancelable/Abortable #131

toastal opened this issue Jul 5, 2020 · 2 comments

Comments

@toastal
Copy link

toastal commented Jul 5, 2020

Given Reader.read() is an asynchronous effect, it should be able to be canceled. The native FileReader has an abort() method, however this is not directly exposed.

Luckily JavaScript doesn't have a private methods/encapsulation; I've not tested yet, but I'll try Reader._getFileReader().abort().

@aadsm
Copy link
Owner

aadsm commented Mar 1, 2021

That's going to be tricky because not all file readers will allow cancelling so can't put it as the generic interface.

@toastal
Copy link
Author

toastal commented Mar 1, 2021

tryAbort() that catches the uncancelable effect as a success? Or expose it and let the user do the catching? This library API is currently lacking without cancel/abort as it doesn't fit a Future or Aff (or other names) interface for asynchronous effects. Fluture is one JavaScript implementation of said specs.

This has been one of the criticisms of the Promise API and AbortControllers have been bolted on to deal with this issue in hindsight. It helps consumers when APIs are fleshed out with the ability to abort/cancel an asynchronous task.

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

2 participants