Skip to content

Instantly share code, notes, and snippets.

@SEUH
Created February 26, 2019 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SEUH/9ff0bcacb32fdbcdf84efa558aed8a2a to your computer and use it in GitHub Desktop.
Save SEUH/9ff0bcacb32fdbcdf84efa558aed8a2a to your computer and use it in GitHub Desktop.
Laravel Echo (Pusher) initial channel subscribed event
// Subscribe to channel 'user.$id'
window.Echo.private('user.' + window.Laravel.user)
.listen('PrivateEvent', (e) => {
console.log(e);
});
// Get pusher instance and add pushers cahnnel event to detect when the channel is subscribed
window.Echo.connector.pusher.channels.channels['private-user.' + window.Laravel.user].bind('pusher:subscription_succeeded', function() {
console.log('channel subscription suceeded');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment