-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate subscribe messages! #343
Comments
Quote from the documentation unsubscribe(callback)Unregisters as a subscriber for the topic. Unsubscribing stop remove all subscribe callbacks. To remove a call back, you must explicitly pass the callback function in. callback: the optional callback to unregister, if * provided and other listeners are registered the topic won't * unsubscribe, just stop emitting to the passed listener |
Can you show me example? Didn't understand |
Something like this (not tested) function handler(message) {
console.log(message);
listener.unsubscribe(handler);
}
listener.subscribe(handler); |
Hey, did you figure out the solution for this? |
@asvinp @fabioaraujopt Any solution? I'm unsuscribing by providing the callback to the unsubscribe function but I'm ending up with an error. |
I had this issue when using React Hooks. I was clicking a button to get subscribed and then again the same button to get unsubscribed from a topic.
|
@ManuelZ |
* Refactor OccupancyGrid to add two methods. These methods can be overwritten by subclasses to extend the OccupancyGrid's rendering behavior (for example adding a colormapping feature). * getColor() - determine the color for a data cell * getValue() - determine the value for a data cell * Change method documentation to mention rgba support * Track resources and add dispose()
I'm using the following configuration:
`var ros = new ROSLIB.Ros({
url : 'ws://x.x.x.x:9090'
});
listener=new ROSLIB.Topic({
ros : ros,
name : '/vigil/sensor/gps/navsatfix',
messageType : 'sensor_msgs/NavSatFix'
});
listener.subscribe(function(message){
listener.unsubscribe();
console.log(message);
});
`
I placed the subscribe function inside a javascript setInterval, in order to call it everytime i need data, instead of being always listening to broadcast. However every time a new subscribe is done. The number of response doubles. (I think it receives all messages from begin).
first_call -> 1 log first_call -> 3 logs first_call -> 4 logs first_call -> 5 logs first_call -> 6 logs
The text was updated successfully, but these errors were encountered: