-1

ai am creating application with naticescript and angular. I have implemented progress indicator with messages. While testing from angular components everything works fine however when i start using real nativescript-background-http progress indicator view seems gets detached because it stops updating untill either i call detectChanges in view or post messages from upload functionallity with ngZone.run. This all would be understandable but later in sequence i have other messages posted (rxjs) to same progress indicator from normal component and i see them comming in console but display value is not updated.

Why progress indicator, which lives in separate component, gets detached?

  • What you even mean "progress indicator view", are you using a plugin or built-in activity indicator? Can you share some code? – Manoj Apr 12 '20 at 23:02
  • I know this was too difficult to explain and understand. But i was able to solve this issue. progress inidicator view (view in which i am using progress component) was handling events comming from rxjs which were detached from zone. – Vytautas Pranskunas Apr 13 '20 at 09:33

1 Answers1

0

I was able to solve this issue. I was completing observable outside Angular Zone.

task.on('progress', (e) => {
                if (e.currentBytes) {
                    // console.log('progress ->', e.currentBytes);
                    this.ngZone.run(() => {
                        this.componentService.loadingIndicator.showProgress({ maxValue: e.totalBytes, value: e.currentBytes });
                    });
                }
            });
            task.on('error', (e) => {
                this.ngZone.run(() => {
                    observer.error(e.error);
                    observer.complete();
                });
            });
            task.on('complete', (e: any) => {
                this.ngZone.run(() => {
                    observer.next(JSON.parse(e.response.getBodyAsString()));
                    observer.complete();
                });
                console.log('complete upload');
            });