Skip to content

[REQUEST] Add a Realtime module to the pure-Dart insforge package (parity with @insforge/sdk and the Kotlin SDK) #13

Description

@warcayac

We build Flutter apps against InsForge tenant backends using the pure-Dart insforge
package (deliberately chosen over insforge_flutter so we can control session storage
ourselves via the injectable SessionStorage interface). The backend's realtime
feature is already provisioned server-side for our tenants (channel patterns such as
authz_user:% with realtime.publish triggers, RLS-governed channel access).

Gap

  • The TypeScript SDK (@insforge/sdk) and the Kotlin SDK both expose a realtime
    module: connect, subscribe, publish, on, disconnect, plus presence.
  • The pure-Dart package (0.1.0) has no realtime module at all.

Use case (concrete)

Postgres-changes-style authorization watch: after sign-in, a Flutter app must react
immediately when an admin changes the user's role/status (e.g., suspension) so the
session can be force-refreshed. The backend publishes those events on the per-user
channel authz_user:{userId}. Without an SDK realtime module, clients are forced to
poll the public.t_get_authz_snapshot RPC on an interval — adding latency (up to one
poll interval before a suspended user is locked out) and consuming egress budget,
which the SDK docs themselves discourage ("never poll unbounded on an interval").

Request

A realtime module in the pure-Dart package mirroring the JS/Kotlin surface:

  1. connect/disconnect lifecycle with channel subscribe/unsubscribe.
  2. Event callbacks (on) for channel messages.
  3. Presence snapshots and join/leave deltas, if the backend contract matches the JS SDK.
  4. Transparent reuse of the authenticated session (access token / refresh via the
    existing AuthClient + SessionStorage wiring), so realtime works both for
    anonymous and authenticated channels.
  5. Keep it consistent with the existing package style (dio-based HTTP client,
    injectable seams), so it remains usable without insforge_flutter.

Alternatives (non-preferred)

  • Raw WebSocket integration per app duplicates SDK responsibilities (auth headers,
    reconnect/backoff, channel protocol) and drifts from the platform contract as it
    evolves.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions