on method

EventManager on(
  1. Window window,
  2. EventType type,
  3. WindowListener callback
)

Implementation

EventManager on(Window window, EventType type, WindowListener callback) {
  var key = type.name;
  log("[event] register listener $key for $window");
  // w.id -> w -> type -> [cb]
  if (_listeners[window.id] == null) _listeners[window.id] = {};
  if (_listeners[window.id]![key] == null) _listeners[window.id]![key] = {};
  if (_listeners[window.id]![key]![window] == null)
    _listeners[window.id]![key]![window] = [];
  if (!_listeners[window.id]![key]![window]!.contains(callback))
    _listeners[window.id]![key]![window]!.add(callback);
  return this;
}