emit method

void emit (
  1. String eventId
)

emit adds an Event to the Stream, notifying all listeners of the action.

Implementation

void emit(String eventId) async {
  /// [Stream.add] will throw an [Exception] if it's [Stream] is closed. [try]
  /// /[catch] used to ensure that it is caught.
  try {
    /// [Stream.add]
    await _controller.add(eventId);

    /// add 1 to _eventCount
    _eventCount++;
  } catch (e) {
    /// if [emit] fails, it is likely due to the [Stream] being closed, but
    /// the [Error] is also printed, just in case. This can be changed to an [Exception]/[Error] if one would like to [catch] their own and send to a `logger`, etc.
    print(
        'This Stream is likely closed. Please see this Error Message for further details: $e');
  }
}