Events
An event is a named message with a JSON payload, published to a channel and delivered to every subscriber.
What an event is
An event is a named message carrying an arbitrary JSON payload. You publish it to a channel from a trusted server; EmitWave delivers it to every connected subscriber bound to that event name (or bound with bindAll).
Three things define a delivery: the channel it is published to, the event name, and the data payload.
Publishing an event
Every server SDK exposes the same shape — trigger(channel, event, data) — and signs the request with HMAC-SHA256 before sending it to the gateway.
// channel, event name, and arbitrary JSON data await emitwave.trigger('orders', 'order.created', { id: 'ord_123', total: 4900, })
See Publishing for the full signed path and the gateway endpoint.
Receiving an event
const channel = await emitwave.subscribe('orders') channel.bind('order.created', (data) => { // data is the JSON you published console.log(data.id, data.total) })
Event naming
Event names are free-form strings you choose; a dotted, domain-style convention such as order.created or message.updated keeps handlers readable. The name is matched exactly by bind().
Reserved SDK events
A few event names are produced by the SDK itself rather than the server, and are not passed to bindAll():
| Event | When it fires |
|---|---|
| cache_miss | A cache channel had no retained event on first subscribe |
| decryption_error | An encrypted payload could not be decrypted |