bind method

Cleanup bind(
  1. ControlHandler handler, {
  2. required Set<ControlEvent> matchers,
  3. Set<String> groups = const {},
})

Answers any of matchers with handler, until the returned Cleanup is called or the Node.build that bound it is gone.

Where several live handlers match one event the topmost node wins and the rest never run, as a hit test would pick it.

groups gates the handler: it answers if at least one group is enabled. If groups is empty, it always answers.

Implementation

Cleanup bind(
  ControlHandler handler, {
  required Set<ControlEvent> matchers,
  Set<String> groups = const {},
}) {
  final control = _Control(
    handler,
    .of(matchers),
    .of(groups),
    building,
  );

  _controls.add(control);
  return scope(() => _controls.remove(control));
}