question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request: add `unlisten` method

See original GitHub issue

I need to stop listening for some events when the route changes (client-side). Currently I use leave(channel), however, this might unsubscribe other events that were registered somewhere else in the app.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:25
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
GovarJabbarcommented, Oct 19, 2020

window.Echo.leave('channel-name')

4reactions
IfnotFrcommented, Mar 7, 2018

The stopListening method will only work with pusher driver.

With SocketIO there is no way to remove a previously added listener through Echo. The only way is to use the SocketIO API directly.

Adding a listener :

Echo.connector.socket.on('blah', listener)

Removing the listener :

Echo.connector.socket.removeListener('blah', listener)

But with this method you may verify the channel provenance as it will listen all subscriptions.

If we want a straightforward native solution we may need to add a way for reverting the on method :

  • Allow unbind to be specific instead of global
  • Save on the fly listener for reusing him for the removal
  • Create a unlisten with :
this.socket.removeListener(event, previousListener); // With our previous on the fly listener
this.unbind(event, listener); // With our new specific unbinder
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unlisten Method
Unlisten Method. In This Topic. Description; Syntax; Parameters; Remarks; See Also. Description. Closes a 'listening' TCP port.
Read more >
JS - keyboard events - listen / unlisten - Stack Overflow
As it is possible to add many Swipes on the same page, I start to listen the keydown events only when any Swipe...
Read more >
EventTarget.removeEventListener() - Web APIs | MDN
The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.
Read more >
Four ways of listening to DOM events in Angular (Part 3
addEventListener in the following way: nativeElement.addEventListener("mousemove", onMouseMove);. To remove this event listener, we need to call .
Read more >
@puttest.io/put-jayson - npm
const jayson = require('jayson'); // create a server const server = new jayson.Server({ add: function(args, callback) { callback(null, args[0] + args[1]); } ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found