Skip to content

A method to stop listening for the notification event #271

@sudkumar

Description

@sudkumar

Echo provides the functionality to listen a laravel notification events which internally calls the listen method on channel instance i.e.

notification(callback: Function): Channel {
  // internally calls the listen method for the notification event
  return this.listen(
    '.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated',
    callback
  );
}

This way, we don't have to provide the notification event name.

But when unsubscribing from the channel, we have to pass the notification event name

const channel = new Echo(...)
channel.notification(() => {})

// when finished
channel.stopListening('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated')

It would be better if we could provide a method on the channel instance that would do it.

+ stopListeningForNotification (): Channel {
+    return this.stopListening('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated')
+ }

Please let me know what do you think. I would love to contribute.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions