addCancellationListener method

void addCancellationListener(
  1. void callback(
    1. WASIComponentSubtask subtask
    )
)

Adds a cancellation callback without replacing an existing callback.

Implementation

void addCancellationListener(
  void Function(WASIComponentSubtask subtask) callback,
) {
  final previous = _onCancel;
  if (previous == null) {
    _onCancel = callback;
    return;
  }
  _onCancel = (subtask) {
    previous(subtask);
    callback(subtask);
  };
}