From 7e0996622d3f134dbc006756e4ecbc9f56997f4f Mon Sep 17 00:00:00 2001 From: Joe Tannenbaum Date: Wed, 1 Oct 2025 09:28:27 -0400 Subject: [PATCH 1/2] Update broadcasting.md --- broadcasting.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/broadcasting.md b/broadcasting.md index 98075d4b7d1..b4ed0d9dc51 100644 --- a/broadcasting.md +++ b/broadcasting.md @@ -1697,3 +1697,23 @@ 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. + + + +### 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); +``` \ No newline at end of file From 39abaf1c82217033d18a39860d9692f2e10b0334 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 1 Oct 2025 15:13:12 +0100 Subject: [PATCH 2/2] Update broadcasting.md --- broadcasting.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/broadcasting.md b/broadcasting.md index b4ed0d9dc51..4f776cc0660 100644 --- a/broadcasting.md +++ b/broadcasting.md @@ -1698,9 +1698,8 @@ 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. - -### Stop Listening for Notifications +#### 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: @@ -1709,11 +1708,11 @@ const callback = (notification) => { console.log(notification.type); } -// Start listening +// Start listening... Echo.private(`App.Models.User.${userId}`) .notification(callback); -// Stop listening (callback must be the same) +// Stop listening (callback must be the same)... Echo.private(`App.Models.User.${userId}`) .stopListeningForNotification(callback); -``` \ No newline at end of file +```