Skip to content

Use case

Live dashboards

A dashboard that polls is wrong between requests, and expensive in proportion to how wrong you let it be. Publishing on change inverts that.

private-metrics
  • private channels
  • events
  • webhooks

How it works

  1. 01Subscribe on openA private channel scoped to whatever the dashboard is displaying.
  2. 02Publish on changeAn event when a figure moves, rather than on a timer nobody tuned.
  3. 03Only compute when watchedOccupancy webhooks let an expensive aggregation run only while somebody is looking.

Worth knowing

A metric that moves hundreds of times a second should be batched or sampled before publishing. That decision belongs where the meaning is — your side.

In code

webhooks.js
js
// Start the aggregation when the first viewer arrives,// stop it when the last one leaves.for (const event of hook.getEvents()) {  if (event.name === 'channel_occupied') startAggregation(event.channel)  if (event.name === 'channel_vacated') stopAggregation(event.channel)}

Written with the official Pusher libraries, unmodified — there is no PushCaster package to install. Full documentation

Other things people build

All use cases
presence-room-42

Realtime chat

Rooms, membership and typing indicators on presence channels.

private-user-1e9

Notifications

One server event, delivered to every surface a user has open.

Create an application and build it.

Support