Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

startEventsSubscriptionAsync does not return List<Event> until Timeout is completed #7

Open
juliancoronado opened this issue Jun 22, 2024 · 0 comments

Comments

@juliancoronado
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant