{ "id": "61418", "key": "TIMOB-786", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11224", "name": "Release 1.4.0", "archived": true, "released": true, "releaseDate": "2010-07-16" } ], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2011-04-15T02:36:25.000+0000", "created": "2011-04-15T02:36:22.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-02T18:40:41.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "{html}
add this code to app.js
\nTi.App.addEventListener('hello', function(){
\nTi.API.info('Hello event fired!');\nTi.App.removeEventListener('hello', this);
\n
\n});
\nTi.App.fireEvent('hello');
Worse than expected. The 'this' symbol does not play nice in a\nlot of situations.
Okay, see http://www.quirksmode.org/js/this.html.\nApparently 'this' is supposed to screw up if you don't use it when\na function is bound to an object, but we should still consider it a\n(low-priority) issue.
I have windows with events that I would like to fire only once.\nI'm using the code pattern above to remove the event promptly, but\nit crashes at removeEventListener. Know of a workaround?
I think this will do what you want (let me know if it\ndoesn't):
\n\na.addEventListener('action', function(e) {\n // Do stuff\n Ti.App.removeEventListener('action', e.source);\n}
\n
\nThis will probably have to be the pattern you use in the future\nas well. 'this' support in event listeners was erroneous in 0.8\nbecause an event listener isn't REALLY a function attached to an\nobject (see the link in the above comments for more).
That works. Thanks Stephen!
Whoops, I take that back. It doesn't seem to work.
Can you give me any additional information about the failure, or\nis it just that the event listener isn't removed? I can create a\nbug for this if there isn't one already.
The event listener appeared not to be removed.
Thanks for the information. I've created #1043 and\nwill address the issue as quickly as I can.
Thanks Stephen
Justin, I updated #1043 with some sample code that shows how to\nappropriately remove an event listener. Please let me know if it\ndoesn't work for you in that ticket, and re-open it if\nnecessary.
Currently using that, thanks Stephen.
See #1043. Also, functions in event listeners do not\nbelong to an object; they're callbacks. Marking this invalid.