Skip to content

Proposal: Client notification system #254

@terrablue

Description

@terrablue

Problem

Client-side code (form submissions, navigation, async actions) can encounter errors that are not tied to any specific UI component — network failures, server errors, session expiry. Currently there is no way to surface these app-wide.

Proposed API

A simple event-bus on client:

client.notify(message: string, level?: "info" | "warn" | "error")

Any client-side code can call it. The root layout subscribes and renders notifications however the app wants — toast, banner, overlay.

Subscription side (in root layout component):

client.on("notify", (message, level) => {
  // push to local notification state
});

Integration points

  • createForm calls client.notify(...) on network error instead of setErrors
  • boot.ts global submit/navigate error handlers call it too
  • Primate users can call it from their own route handlers or components

Non-goals

  • No built-in UI — Primate provides the mechanism, the app owns the rendering
  • No persistence — notifications are ephemeral, in-memory only

Actionables

  1. Implement client.notify / client.on event bus in client/index.ts
  2. Update createForm and boot.ts to use it
  3. Add example notification component to docs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions