tapEachEvent method

Stream<List<XmlEvent>> tapEachEvent({
  1. EventHandler<XmlCDATAEvent>? onCDATA,
  2. EventHandler<XmlCommentEvent>? onComment,
  3. EventHandler<XmlDeclarationEvent>? onDeclaration,
  4. EventHandler<XmlDoctypeEvent>? onDoctype,
  5. EventHandler<XmlEndElementEvent>? onEndElement,
  6. EventHandler<XmlProcessingEvent>? onProcessing,
  7. EventHandler<XmlStartElementEvent>? onStartElement,
  8. EventHandler<XmlTextEvent>? onText,
})

Executes the provided callbacks on each event of this stream as a side effect.

Returns the unmodified stream of events. Note that this does not start processing the events unless somebody subscribes to the stream.

Implementation

Stream<List<XmlEvent>> tapEachEvent({
  EventHandler<XmlCDATAEvent>? onCDATA,
  EventHandler<XmlCommentEvent>? onComment,
  EventHandler<XmlDeclarationEvent>? onDeclaration,
  EventHandler<XmlDoctypeEvent>? onDoctype,
  EventHandler<XmlEndElementEvent>? onEndElement,
  EventHandler<XmlProcessingEvent>? onProcessing,
  EventHandler<XmlStartElementEvent>? onStartElement,
  EventHandler<XmlTextEvent>? onText,
}) {
  final handler = XmlEventHandler(
    onCDATA: onCDATA,
    onComment: onComment,
    onDeclaration: onDeclaration,
    onDoctype: onDoctype,
    onEndElement: onEndElement,
    onProcessing: onProcessing,
    onStartElement: onStartElement,
    onText: onText,
  );
  return map((eventList) {
    eventList.forEach(handler.visit);
    return eventList;
  });
}