close method

  1. @override
Future<void> close({
  1. bool waitForRemainingTasks = false,
})
override

Closes the current Worker. CombineWorker is a singleton but under the hood it uses a worker manager instance which can be closed and recreated. It may be useful if you want to cancel all running and awaiting tasks (i. e. on user logout).

If waitForRemainingTasks flag is set to true then worker will be marked as closed but will finish all its tasks. Otherwise all remaining tasks will complete with CombineWorkerClosedException.

You can call execute or initialize methods without awaiting for this future. In that case new isolates' pool will be created.

Implementation

@override
Future<void> close({bool waitForRemainingTasks = false}) async {
  final closeResult = _workerManager?.close(
    waitForRemainingTasks: waitForRemainingTasks,
  );

  _workerManager = null;
  _isInitialized = false;

  return closeResult;
}