-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
Hi,
What could be the reason that when I add a Future to the queue using add, it immediately runs the Future?
I didn’t put an await before queue.add.
I want to collect all of them first, and only when I run onComplete, I want them to execute one after another.
For example:
static Future<void> Function() createOfflineQueueTask({
required Future<void> Function() apiCall,
}) {
return () async {
print("Executing offline API call...");
await apiCall();
print("Finished executing offline API call...");
};
}
apiCall is Future<T?> Function()
queue.add(createOfflineQueueTask(apiCall: apiCall);
And when I want to run them:
queue.onComplete.then((_) {
remainingItemsStream.close();
queue?.dispose();
});
But thequeue.add runs them immediately instead before running the onComplete, why?
Metadata
Metadata
Assignees
Labels
No labels