SequencedTaskBatch<T extends Object>.from constructor

SequencedTaskBatch<T extends Object>.from(
  1. SequencedTaskBatch<T> other, {
  2. TaskSequencer<T>? sequencer,
})

Creates a new batch from an existing one, sharing its configuration.

The new batch will contain a copy of the original tasks but can be assigned a different TaskSequencer. If no sequencer is provided, it reuses the one from the other batch.

Implementation

factory SequencedTaskBatch.from(
  SequencedTaskBatch<T> other, {
  TaskSequencer<T>? sequencer,
}) {
  final newBatch = SequencedTaskBatch<T>(
    sequencer: sequencer ?? other._sequencer,
  );
  // Create a new independent queue with the same tasks.
  newBatch.tasks.addAll(other.tasks);
  return newBatch;
}