Notifications

Events

Simple Interactive Server

Buttons four levels deep raise toasts in a host that sits somewhere else entirely, with no parameters or callbacks passed between them.

How it works

Try it: send a few notifications, hide the listeners, send more, then show them again.

  • NotifyButton publishes ToastRequested (an IEvent) and updates NotificationStats (an IState).
  • ToastHost subscribes with [Subscribe(Scope = ScopeKind.Root)], so it hears publishes from anywhere.
  • EventHistory only counts events received while mounted. Events have no current value, so a late subscriber misses earlier ones.
  • SentCounter reads state, so it always shows the full total, including notifications sent while it was hidden.
  • This page runs on Interactive Server, so the hub lives in the user's circuit. Another browser tab has its own circuit and its own hub.

Deeply nested publishers

level 1
level 2
level 3
level 4

Events vs. state

Events received since this listener appeared: 0

    Notifications sent (state): 0

    An unhandled error has occurred. Reload 🗙