To unregister a listener from a port, you can do:
app.port.unsubscribe(myListener)
Is there a way to unregister all the listeners to a given port, without calling unsubscribe explicitely for each one? I would like to be sure I won't forget any listener. I tried by calling unsubscribe() without any parameter, but it does not seem to have any effect.
This is not currently possible. You can see the exposed API for ports here:
The subs
array is not exposed, so by default, there's no way to get at it without having the original callback.
If this functionality is important to you however you might consider writing a wrapper on the Javascript side that keeps track of your subscribed callbacks for you, which you could use to implement an unsubscribeAll
yourself.