Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19641] Create a function to check for an existing listener

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsTiAPI
Labelslisteners
ReporterManuel Conde Vendrell
AssigneeUnknown
Created2015-09-29T16:05:11.000+0000
Updated2018-02-28T19:55:46.000+0000

Description

Sometimes would be really useful to know if there is an event attached to an object. For example, let's say we want to attach *Ti.App.addEventListener('app:whatever', myfunction)* but, to avoid double attach, we want to check previously if it is not attached yet. Something like *Ti.App.hasListener('app:whatever')* would be really useful to do a check before attach. P.d.- I know *Ti.App.add...* is not recommended, but sometimes is better than other possibilities.

Comments

  1. Hazem Khaled 2015-12-23

    +1
  2. Rene Pot 2015-12-23

    Would love to see this implemented. Currently the only way to prevent double binding, is try and remove it first...
  3. Chee Kiat Ng 2015-12-29

  4. Manuel Conde Vendrell 2015-12-29

    If double binding if fixed with this solution, of course could be a valid solution (I suppose the fix would be for iOS/Android/WP and for all listeners). Cannot imagine right now any case in that a user could need a double binding for the same listener. But if that case exists, then a check function would be the real solution.

JSON Source