observe method

void observe(
  1. List<Observable> observables,
  2. {bool reset = true}
)

Listen to observables changes and call notifyListeners when a new value is added to the stream.

@param reset - whether to reset all the existing observables' listeners before adding the new ones.

Implementation

void observe(List<Observable> observables, {bool reset = true}) {
  if (reset) clearAllObservers();

  observables.forEach((observable) {
    final subscription = observable.stream.listen((_) => notifyListeners());

    _observablesSubcriptions[observable] = subscription;
  });
}