{ "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

\n

Ti.App.addEventListener('hello', function(){

\n
\nTi.API.info('Hello event fired!');\nTi.App.removeEventListener('hello', this);\n
\n

});

\n

Ti.App.fireEvent('hello');

{html}", "attachment": [], "flagged": false, "summary": "crash using 'this' in removeEventListener", "creator": { "name": "nwright", "key": "nwright", "displayName": "Nolan Wright", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "nwright", "key": "nwright", "displayName": "Nolan Wright", "active": false, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "124027", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Worse than expected. The 'this' symbol does not play nice in a\nlot of situations.

{html}", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:36:23.000+0000", "updated": "2011-04-15T02:36:23.000+0000" }, { "id": "124028", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

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.

{html}", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:36:23.000+0000", "updated": "2011-04-15T02:36:23.000+0000" }, { "id": "124029", "author": { "name": "justin", "key": "justin", "displayName": "Justin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

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?

{html}", "updateAuthor": { "name": "justin", "key": "justin", "displayName": "Justin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:36:23.000+0000", "updated": "2011-04-15T02:36:23.000+0000" }, { "id": "124030", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

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
\n

This 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).

{html}", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:36:23.000+0000", "updated": "2011-04-15T02:36:23.000+0000" }, { "id": "124031", "author": { "name": "justin", "key": "justin", "displayName": "Justin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

That works. Thanks Stephen!

{html}", "updateAuthor": { "name": "justin", "key": "justin", "displayName": "Justin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:36:23.000+0000", "updated": "2011-04-15T02:36:23.000+0000" }, { "id": "124032", "author": { "name": "justin", "key": "justin", "displayName": "Justin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Whoops, I take that back. It doesn't seem to work.

{html}", "updateAuthor": { "name": "justin", "key": "justin", "displayName": "Justin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:36:23.000+0000", "updated": "2011-04-15T02:36:23.000+0000" }, { "id": "124033", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

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.

{html}", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:36:23.000+0000", "updated": "2011-04-15T02:36:23.000+0000" }, { "id": "124034", "author": { "name": "justin", "key": "justin", "displayName": "Justin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

The event listener appeared not to be removed.

{html}", "updateAuthor": { "name": "justin", "key": "justin", "displayName": "Justin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:36:24.000+0000", "updated": "2011-04-15T02:36:24.000+0000" }, { "id": "124035", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Thanks for the information. I've created #1043 and\nwill address the issue as quickly as I can.

{html}", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:36:24.000+0000", "updated": "2011-04-15T02:36:24.000+0000" }, { "id": "124036", "author": { "name": "justin", "key": "justin", "displayName": "Justin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Thanks Stephen

{html}", "updateAuthor": { "name": "justin", "key": "justin", "displayName": "Justin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:36:24.000+0000", "updated": "2011-04-15T02:36:24.000+0000" }, { "id": "124037", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

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.

{html}", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:36:24.000+0000", "updated": "2011-04-15T02:36:24.000+0000" }, { "id": "124038", "author": { "name": "justin", "key": "justin", "displayName": "Justin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Currently using that, thanks Stephen.

{html}", "updateAuthor": { "name": "justin", "key": "justin", "displayName": "Justin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:36:24.000+0000", "updated": "2011-04-15T02:36:24.000+0000" }, { "id": "124039", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

See #1043. Also, functions in event listeners do not\nbelong to an object; they're callbacks. Marking this invalid.

{html}", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:36:25.000+0000", "updated": "2011-04-15T02:36:25.000+0000" }, { "id": "408366", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing as invalid.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-02T18:40:41.000+0000", "updated": "2017-03-02T18:40:41.000+0000" } ], "maxResults": 14, "total": 14, "startAt": 0 } } }