-
Notifications
You must be signed in to change notification settings - Fork 160
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
cancel a compression in progress [feature request] #101
Comments
It'd be great if you expose the |
Something like a cancelToken that contains a Promise, which can be resolved/rejected by the user. |
In the coming releases, we will use AbortController for canceling mechanism: reference: https://axios-http.com/docs/cancellation |
This feature is implemented in v2.0.0. For example: function handleImageUpload(event) {
var imageFile = event.target.files[0];
var controller = new AbortController();
var options = {
// other options here
signal: controller.signal,
}
imageCompression(imageFile, options)
.then(function (compressedFile) {
return uploadToServer(compressedFile); // write your own logic
})
.catch(function (error) {
console.log(error.message); // output: I just want to stop
});
// simulate abort the compression after 1.5 seconds
setTimeout(function () {
controller.abort(new Error('I just want to stop'));
}, 1500);
} |
Some compressions (very large resolutions and bytes in size) can take a while and be CPU expensive. It should be a way to cancel a compression in progress in WebWorker mode (example of use cases: in SPA, when user remove file from form or change file again).
The text was updated successfully, but these errors were encountered: