dispatch method

void dispatch(
  1. List<T> observers,
  2. void func(
    1. T,
    2. String
    )
)

Given a list of observers, call func(observer, string).

If the given observer is a key in targetedStrings, the passed string will be the associated value.

If not, the passed string will be defaultString.

The func argument should pass the given string to the given observer.

Implementation

void dispatch(List<T> observers, void Function(T, String) func) {
  for (final T observer in observers) {
    final String value = targetedStrings[observer] ?? defaultString;
    func(observer, value);
  }
}