簡體   English   中英

在返回 FirebaseFirestore QuerySnapshot 時使用 async* 和 yield* 有什么區別嗎

[英]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.

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