离线数据查询速度很慢,并且似乎正在传播

我正在使用Firebase / Firestore

这是我的服务电话。

fetchClients(): Observable<Array<Client>> {

        return new Observable<Array<Client>>(observer => {              

            this.authSvc.getauthClaim().subscribe(authClaim => {
                this.db.collection(this.collectionName,ref => ref.where("companyID","==",authClaim.companyID))
                    .get()
                    .subscribe((snapshot: Querysnapshot<any>) => {
                        const clientList = snapshot.docs.reduce((aggClientList,client) => {
                            const clientData = client.data();
                            clientData.clientID = client.id;
                            aggClientList.push(new Client(clientData));

                            return aggClientList;
                        },[]);

                        observer.next(clientList);
                        observer.complete();
                    },(error) => {
                        observer.error({ error: error,friendlyError: "There was an error fetching the client list" });
                        observer.complete();
                    });
            });

        });

}

每次用户导航到客户端列表页面时都会调用此名称。

如果您多次浏览至此页面,我会在离线状态下注意到更多,每次浏览(传播)请求时所花费的时间越来越长。

即使这是正在发生的事情,如何防止呼叫“重叠”?第一次加载似乎是瞬时的,而随后的加载似乎在时间上是相互关联的。难道不应该立即获取缓存的Firestore数据吗?

谢谢!

tmroybq 回答:离线数据查询速度很慢,并且似乎正在传播

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3156018.html

大家都在问