[TIMOB-19641] Create a function to check for an existing listener
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Low |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | TiAPI |
Labels | listeners |
Reporter | Manuel Conde Vendrell |
Assignee | Unknown |
Created | 2015-09-29T16:05:11.000+0000 |
Updated | 2018-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.
+1
Would love to see this implemented. Currently the only way to prevent double binding, is try and remove it first...
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.