From e70c29a7328ee3db6399f7ca30e1d5a8114d072b Mon Sep 17 00:00:00 2001 From: Himchan Park Date: Wed, 8 Jan 2025 14:26:57 +0900 Subject: [PATCH] Improve performance of `watch` --- packages/isar/lib/src/query_extensions.dart | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/packages/isar/lib/src/query_extensions.dart b/packages/isar/lib/src/query_extensions.dart index 6d0892db5..00ddb9595 100644 --- a/packages/isar/lib/src/query_extensions.dart +++ b/packages/isar/lib/src/query_extensions.dart @@ -257,19 +257,8 @@ extension QueryExecute on QueryBuilder { int? offset, int? limit, }) { - final q = build(); - final controller = StreamController>(); - q - .watch(fireImmediately: fireImmediately, offset: offset, limit: limit) - .listen( - controller.add, - onError: controller.addError, - onDone: () { - controller.close(); - q.close(); - }, - ); - return controller.stream; + return watchLazy(fireImmediately: fireImmediately) + .map((_) => findAll(limit: limit, offset: offset)); } /// {@macro query_watch_lazy}