/// Created by @Haoyi on 2021/7/7
///
///

part of "extensions.dart";

extension SubjectExtension<T> on BehaviorSubject<T> {
  void addEx(T event) {
    if (!isClosed) {
      add(event);
    }
  }

  bool addIfChanged(T event) {
    if (!isClosed && value != event) {
      add(event);
      return true;
    }
    return false;
  }
}

extension StreamControllerExtension<T> on StreamController<T> {
  void addEx(T event) {
    if (!isClosed) {
      add(event);
    }
  }
}

extension FutureExtension<T> on Completer<T> {
  void safeComplete([FutureOr<T>? value]) {
    if (isCompleted) {
      return;
    }
    complete(value);
  }
}
