add method

void add(
  1. T object
)

inserts a new object in the manager. This will initialize a new cubit bound to this object, or update the current one using updateCubit. You can obtain the binded cubit by calling get

Implementation

void add(T object) {
  final id = buildId(object);
  final cubit = _cubits[id];

  if (cubit == null) {
    // l'objet n'existe pas encore, on l'ajoute
    _cubits[id] = create(object);
  } else {
    // la collection contient déjà cet identifiant
    if (cubit.isClosed) {
      // le cubit n'est plus actif, on le remplace par un nouveau
      remove(object);
      add(object);
    } else {
      updateCubit(cubit, object);
    }
  }
}