Skip to Content
APIPublic channel

Public channel

Public channels should be used for publicly accessible data as they do not require any form of authorization in order to be subscribed to.

You can subscribe and unsubscribe from channels at any time. There’s no need to wait for the Channels to finish connecting first.

Subscribe

Create a subscription to a specific channel. Provide any required parameters for public, private or presence channels.

const = .('application', { :'public', : {} })

Unsubscribe

Stop receiving events and clear all listeners from the subscription.

.();

Events

Listen for an event

Subscribe to a specific event on the channel.

.('newVersionAvailable', () => { /** Do something with the event **/ })

Stop listening for an event

This should only be used when you want to stop listening for a specific event without unsubscribing from the channel; otherwise, calling sub.dispose() is sufficient.

Remove a specific listener using either the returned unsubscribe function or the original callback reference.

const = .('newVersionAvailable', () => { /** Do something with the event **/ }) // Later ();

Notifications

Listen for a notification

Listen for .Illuminate\\Notifications\\Events\\BroadcastNotificationCreated event on a channel.

.(() => { /** Do something with a notification event **/ });

Stop listening for a notification

This should only be used when you want to stop listening for a specific event without unsubscribing from the channel; otherwise, calling sub.dispose() is sufficient.

// Using returned unsubscribe function const = .(() => { /** Do something with a notification event **/ }); ()

Internal Events

Subscription succeeded

Triggered when the subscription is successfully established.

.(() => { /** Do something after successful subscription **/ })