我们使用以下代码创建了一个应用,该应用具有对 Firestore 中查询的侦听器:
/**
* Client callback list generation
*/
private incoming_online_client_for_any_care = (domain: string) => {
return this.db.collection<db.callingClient>(`domains/${domain}/callingClients`, ref => {
let query: firebase.firestore.CollectionReference | firebase.firestore.Query = ref;
query = query.where('for', 'array-contains', 'any')
.where('status', '==', 'is_calling');
return query;
}).valueChanges();
}
当我们将页面打开几分钟时,应用似乎不再响应此查询的更改(实际上,当另一个页面上的用户打开应用时,将设置或删除 is_calling)。
页面刷新立即生效。
它是通过调用这个函数创建的:
this.clientsForAnyCare$ = this.incoming_online_client_for_any_care(domain);
管道:(this.allClients$ 是一个数据库调用,用于用名称等丰富客户端)
.pipe(
map(([a, b]) => {
return uniqWith(
sortBy(
a, ['timestamp']
)
).map(callingClient => {
if (callingClient) {
... enrich code
}
return callingClient;
})
}),
);
And used in the template
``` <ng-container *ngIf="nextClient$ | async as bellers;wachten">```