broadcast method

void broadcast([
  1. T? args
])

Broadcast this Event to subscribers, with an optional EventArgs argument.

Ignored if no handlers (subscribers). Calls each handler (callback) that was previously added to this Event.

// Example
// Without an [EventArg]
onValueChanged.broadcast();

// With an argument [EventArg]
onValueChanged2.broadcast(ChangedValue(3.14159));

Implementation

void broadcast([T? args]) {
  // ignore if no handlers
  _handlers.forEach((key, handler) {
    handler(args!);
  });
}