Description
Description
startEventsSubscriptionAsync does not complete the Future until the Timeout is completed. The README.md states this:
Note: startEventsSubscriptionAsync will be resolve with an List as soon as a relay sends an EOSE command.
But in my testing, the startEventsSubscriptionAsync method does not resolve even after the relays send an EOSE command.
I tested this behavior by providing the onEose
parameter so I can see when each relay returns the command. However, when the EOSE is returned to the app, the Future continues until the Timeout is done.
Code Sample
Future<void> fetchUserEvents() async {
List<NostrEvent> events = [];
final request = NostrRequest(
filters: [
NostrFilter(
limit: 10,
kinds: const [0],
authors: [keyPair.public],
),
],
);
try {
events = await Nostr.instance.relaysService.startEventsSubscriptionAsync(
request: request,
onEose: (relay, command) {
print(relay);
print(command);
},
timeout: const Duration(seconds: 5),
);
} catch (e) {
debugPrint(e.toString());
}
}
Comments
I'm not sure if this is the expected behavior but I think it would be a nice way to get a list of events and then display them to the user. Instead of specifying a Timeout. Perhaps the Timeout value can still be used if the response takes too long, but I think it should be resolved promptly once the List is returned.