broadcast method

void broadcast([
  1. T? args
])

Broadcast this Event to subscribers, with an optional EventArgs derived 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]) {
  for (var i = 0; i < _handlers.length; i++) {
    _handlers[i].call(args);
  }
}