A base class for publishers that process log events asynchronously.
It provides common functionality for queuing incoming log events via a stream and processing them sequentially, forming the foundation for avoiding blocking operations during application execution.
Example usage:
final class FilePublisher extends AsyncPublisherBase<Log> {
@override
Future<void> handle(Log log) async {
// Perform asynchronous file write
await file.writeAsString(log.toString(), mode: FileMode.append);
}
}
- Implemented types
Constructors
- AsyncPublisherBase({bool sync = false, void onError(Object error, StackTrace stackTrace)?})
- Creates the publisher and starts its processing queue.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isClosed → bool
-
Whether close has been called.
no setter
- onError → void Function(Object error, StackTrace stackTrace)?
-
Called when handle throws.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sync → bool
-
Whether the underlying stream controller delivers events synchronously.
final
Methods
-
close(
) → Future< void> -
Closes the publisher after processing the already queued log events.
override
-
flush(
) → Future< void> -
Completes when every log event queued before this call has been
processed.
override
-
handle(
Log log) → FutureOr< void> - Processes a single log event.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
publish(
Log log) → void -
Publishes the given
logevent.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited