apache/incubator-cordova-js — pull request #14 by revolunet (2012-05-28 20:54:18+00:00)
Title: repeated listener failing test

This is a failing test when the same event handler is subscribed many times.

This is related to issue : https://issues.apache.org/jira/browse/CB-829

The problem is that the `subscribe` function set a `observer_guid` to the original callback once only, even if the same callback is attached multiple times. Then, when calling `unsubscribe`, it uses this attribute to detect and remove the handler, only once (https://github.com/apache/incubator-cordova-js/blob/master/lib/common/channel.js#L183); Hence, `this.numHandlers` is not decreased, and `this.events.onUnsubscribe` is not called for subsequent handlers.

Hope this helps.

Sample fix : https://github.com/revolunet/incubator-cordova-android/blob/0c9295f8bcfd801b0dee77b0c16838a856067603/framework/assets/js/cordova.android.js#L643