executeSingleStep<T> method
Future<List<T> >
executeSingleStep<T>({
- required ParallelRequest<
T> request, - List<
NostrEvent> ? initialEvents,
Executes a single parallel request step without chaining.
request - The parallel request to execute
initialEvents - Optional initial events to pass to the request
Returns the adapted results from this single step.
Implementation
Future<List<T>> executeSingleStep<T>({
required ParallelRequest<T> request,
List<NostrEvent>? initialEvents,
}) async {
try {
// Execute the request's filters
final (subId, events) = await _service.getEvents(
filters: request.filters,
);
// Adapt the events using the provided adapter function
final adaptedResults = <T>[];
for (final event in events) {
try {
final adapted = request.adapter(event);
adaptedResults.add(adapted);
} catch (e) {
print('Adapter error for event ${event.id}: $e');
rethrow;
}
}
return adaptedResults;
} catch (e) {
print('Error executing single step: $e');
rethrow;
}
}