让 firestore 不随时重新加载
Make firestore not reload anytime
我实际上是一个人在做一个应用程序,文档有点困难。
这是我的问题:我有这段代码
/**
* @param postId
* @param query
*/
public getCommentToPost(postId: string): Observable<CommentModel[]> {
return this.afStore.collection('posts')
.doc(postId).collection<CommentModel>('comments').valueChanges();
}
afStore
是对 AngularFirestore 的引用; (我正在使用 angularfire2
)。
问题在于,每次最终集合(此处 comments
)发生修改时,所有输出都只是重新加载。
它仍然非常快,但我有时会在其他甚至没有修改的评论上看到小的加载旋转器。
是否可以只加载新评论?
对于 Firestore 中 collection/query 的任何更新,您都会得到受影响的文档 和 对该文档所做的更改类型,即它是否已添加、更改或删除。在 AngularFire2 中,该信息被映射到 DocumentChangeAction
。但是 valueChanges
没有得到 DocumentChangeAction
,所以那里没有关于更改类型的信息。使用其他一种流式传输方法(即 snapshotChanges
)了解所做的更改类型。
我实际上是一个人在做一个应用程序,文档有点困难。
这是我的问题:我有这段代码
/**
* @param postId
* @param query
*/
public getCommentToPost(postId: string): Observable<CommentModel[]> {
return this.afStore.collection('posts')
.doc(postId).collection<CommentModel>('comments').valueChanges();
}
afStore
是对 AngularFirestore 的引用; (我正在使用 angularfire2
)。
问题在于,每次最终集合(此处 comments
)发生修改时,所有输出都只是重新加载。
它仍然非常快,但我有时会在其他甚至没有修改的评论上看到小的加载旋转器。
是否可以只加载新评论?
对于 Firestore 中 collection/query 的任何更新,您都会得到受影响的文档 和 对该文档所做的更改类型,即它是否已添加、更改或删除。在 AngularFire2 中,该信息被映射到 DocumentChangeAction
。但是 valueChanges
没有得到 DocumentChangeAction
,所以那里没有关于更改类型的信息。使用其他一种流式传输方法(即 snapshotChanges
)了解所做的更改类型。