Skip to content

frontend: implement typed WebSocket client wrapper (TS) with topic subscriptions #135

@ayushkrtiwari

Description

@ayushkrtiwari

Goal

Create a robust TypeScript WebSocket client used by cauweb for realtime updates (topics, reconnect, schema validation).

Tasks

  • Add frontend/src/lib/wsClient.ts (TS) implementing:
    • typed message interfaces (Request/Response/Event)
    • subscribe(topic)/unsubscribe(topic) semantics
    • exponential reconnect with jitter and backoff
    • heartbeat/ping-pong handling and stale detection
  • Use JSON Schema or zod for runtime validation of inbound messages.
  • Add a simple mock server used by unit tests and Playwright e2e.
  • Add docs: usage examples and error handling patterns.

Acceptance criteria

  • Components can call useWS.subscribe('price:AAPL') and receive typed messages.
  • Client reconnects and resumes subscriptions automatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Semver:minorminor version changesType:Hardsenior developers, max points

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions