filestack / filestack-js

Official Javascript SDK for the Filestack API and content ingestion system.
https://www.filestack.com
MIT License
206 stars 79 forks source link

Reject the promise returned by filestack.pick when the user closes the dialog #30

Closed mattlewis92 closed 7 years ago

mattlewis92 commented 7 years ago

This is how v2 currently functions. To workaround this in v3 you have to wrap the call to pick in another promise and reject it when the onClose callback is called, which isn't a great developer experience.

velveteer commented 7 years ago

This is probably a good idea insofar that it's coupled with cancelling uploads on close. We would have to update our docs to make it clear that the picker can now reject, since we don't want users getting unhandled rejection errors.

mattlewis92 commented 7 years ago

Alternatively you could have it opt in via a flag 🙂

velveteer commented 7 years ago

I was considering it. Perhaps rejectOnCancel or rejectOnClose (assuming the close cancels in-flight requests)? Something like that. This might address https://github.com/filestack/filestack-js/issues/9. In this case the user can "cancel" by clicking the close button or hitting their escape key. In both of these cases we can offer the ability to reject the Promise returned by pick.

velveteer commented 7 years ago

0.8.0 now includes a rejectOnCancel option.

mattlewis92 commented 7 years ago

Awesome, thanks! 😄