Created
February 26, 2019 15:34
-
-
Save SEUH/9ff0bcacb32fdbcdf84efa558aed8a2a to your computer and use it in GitHub Desktop.
Laravel Echo (Pusher) initial channel subscribed event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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