Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions broadcasting.md
Original file line number Diff line number Diff line change
Expand Up @@ -1697,3 +1697,22 @@ channel().notification((notification) => {
```

In this example, all notifications sent to `App\Models\User` instances via the `broadcast` channel would be received by the callback. A channel authorization callback for the `App.Models.User.{id}` channel is included in your application's `routes/channels.php` file.

<a name="stop-listening-for-notifications"></a>
#### Stop Listening for Notifications

If you would like to stop listening to notifications without [leaving the channel](#leaving-a-channel), you may use the `stopListeningForNotification` method:

```js
const callback = (notification) => {
console.log(notification.type);
}

// Start listening...
Echo.private(`App.Models.User.${userId}`)
.notification(callback);

// Stop listening (callback must be the same)...
Echo.private(`App.Models.User.${userId}`)
.stopListeningForNotification(callback);
```