rndme / download

file downloading using client-side javascript
MIT License
2.29k stars 417 forks source link

Asynchronous? #9

Closed ryandraper closed 8 years ago

ryandraper commented 9 years ago

Hi, thanks for this awesome library. I just have a couple questions.

1.) is the download function asynchronous? 2.) is there a way notify the calling code when it is done?

My motivation for asking is that I want to close the parent window when the download starts or completes. I know this isn't really an issue with the code, just wondering if I can make it do what I want:)

rndme commented 8 years ago

it is 99% sync, but with a small (but needed) delay from the dom. Sadly, you cannot tell from JS when or if the download is done. you can probably catch the simulated click event that initiates the download using event delegation. From what I've seen in the field, you should be able to reliably close your popup using a short (say 50ms) setTimeout called just after download().

ryandraper commented 8 years ago

Thanks for clearing that up for me. Thanks again for the library.