executeStream<T> method
Evaluates and wraps a multi-event data streamFactory pipeline asynchronously.
Listens to individual outgoing events from the underlying stream, yielding each instance as an encapsulated Result.success. Captures terminal sequence stream errors and wraps them safely.
Implementation
Stream<Result<T>> executeStream<T>(
Stream<T> Function() streamFactory, {
String? context,
}) async* {
try {
final stream = streamFactory();
await for (final data in stream) {
yield Result.success(data);
}
} catch (e, stackTrace) {
yield _handleError<T>(e, stackTrace, context);
}
}