NativeScript / nativescript-background-http

Background Upload plugin for the NativeScript framework
Apache License 2.0
101 stars 50 forks source link

Unable to use progress bar with registered upload progress event handler #248

Closed karmabase closed 4 years ago

karmabase commented 4 years ago

Hi, thank you very much for this plugin!

I am having a hard time making a progress bar work with this plugin. It seems that once my component function is registered with task.on("progress"), the function is unable to call any other existing method or update existing variables in my component class.

For eg: Component code: let task = this.uploadService.mobileUploadDocumentBgHttp(some params);//this sends the task object back to the component

task.on("progress", function(e){ let percent = Math.round(e.currentBytes/e.totalBytes*100); this.progressValue = percent; //this doesnt work });

progressValue never gets updated.

What other ways should I try?

support[bot] commented 4 years ago

:wave: @karmabase, we use the issue tracker exclusively for bug reports and feature requests. However, this issue appears to be a support request. Please, use Stackoverflow to get help.

tbozhikov commented 4 years ago

Hi @karmabase, refer to this sample app: https://play.nativescript.org/?template=play-ng&id=pmXu7c&v=15

It features progress bar, fed by data coming from the nativescript-background-http plugin.