monitor static method

Stream<TaskStatus> monitor(
  1. String name
)

Monitors the status of a task by name.

Returns a stream of TaskStatus updates. Example:

TaskFlow.monitor('syncData').listen((status) {
  if (status is TaskRunning) {
    print('Progress: ${status.progress}');
  }
});

Implementation

static Stream<TaskStatus> monitor(String name) {
  return TaskFlowPlatform.instance.taskEvents
      .where((event) => event['taskName'] == name)
      .map((event) => TaskStatus.fromMap(event));
}