簡體   English   中英

nativescript-background-http 分離視圖

[英]nativescript-background-http detaches view

我正在使用 naticescript 和 angular 創建應用程序。 我已經用消息實現了進度指示器。 在從 angular 組件進行測試時,一切正常,但是當我開始使用真正的 nativescript-background-http 進度指示器時,視圖似乎已分離,因為它停止更新,直到我在視圖中調用 detectChanges 或使用 ngZone.run 從上傳功能發布消息。 這一切都是可以理解的,但稍后我將其他消息(rxjs)從普通組件發布到相同的進度指示器,我看到它們在控制台中出現,但顯示值沒有更新。

為什么存在於單獨組件中的進度指示器會分離?

我能夠解決這個問題。 我在 Angular 區域之外完成了 observable。

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');
            });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM