简体   繁体   中英

Show loading progress during Fetch

I followed this code to let user download files to cache to display them offline: https://serviceworke.rs/cache-from-zip.html

It works, but with large files it can take some time so I would like to show a progress indicator while loading the zip file.

I guess it's in the fetch part that it could be done but I don't know how: https://serviceworke.rs/cache-from-zip_worker_doc.html

Declare a let or var variable which is null initially. Then during data fetch assign the response to that variable.

Use an if-else statement to display a spinner while said variable is null.

Upload progress indicators for fetch?

Have a look here, the second answer in particular might be of help to your problem.

EDIT: I am assuming you can derive similar information regardless of up or download - unfortunately not sure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM