[英]Is there any difference between using async* and yield* or not on returning FirebaseFirestore QuerySnapshot
第一種情況和第二種情況有什么區別嗎?
1.
Stream<QuerySnapshot> streamUsersOne() async* {
yield* FirebaseFirestore.instance.collection('users').snapshots();
}
2.
Stream<QuerySnapshot> streamUsersTwo() {
return FirebaseFirestore.instance.collection('users').snapshots();
}
第一個(async* 和 yield)在您創建自己的 Stream 時使用,這里不需要使用它,因為 snapshots 方法已經返回 Stream 類型。 您可以觀看此 剪輯以了解有關如何創建流的更多信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.