cancel method Null safety

bool cancel()

Cancel the event subscription with the subject. Eventhough the cancel method is called, listener doesn't check the cancellation of the subscription. Subscription cancellation shall be implemented in the _cancelCallback function. The Default constructor doesn't provide a mechanism to cancel the subscription. Use the EventEmitter.on to cancel the suscrition effectively. Returns true, if _cancelCallback is successfully executed, false otherwise.

Implementation

bool cancel() {
  if (null != _cancelCallback) {
    _cancelCallback!();
    return true;
  }

  return false;
}