Skip to content

Implement real-time streaming using NRelay1 req() subscriptions #19

Description

@Catrya

Currently the "streaming" mode uses relay.query() which fetches events once and closes the connection. It should use relay.req() to maintain an open subscription and receive new events in real-time.

Current behavior

  • Without limit, the app shows "Streaming..." but only fetches events once
  • User must manually search again to see new events

Expected behavior

  • Without limit, maintain an open WebSocket subscription to the relay
  • Show historical events first, then append new events as they arrive in real-time
  • Stop with "Stop Searching" button or when filters change

Implementation notes

  • NRelay1.req() returns an async generator yielding EVENT, EOSE, and CLOSED messages
  • After EOSE, the subscription stays open and yields new events in real-time
  • NRelay1 has built-in reconnection with exponential backoff and automatic re-subscription
  • Cap displayed events at ~500 (discard oldest when exceeded) to prevent memory growth
  • With limit: keep using query() as-is (one-time fetch)
  • AbortController signal can be used to cleanly close the subscription

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions