{ "id": "79409", "key": "TIMOB-5042", "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": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2011-08-18T07:02:40.000+0000", "created": "2011-08-18T06:08:27.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [], "versions": [ { "id": "11367", "description": "", "name": "Release 1.7.1", "archived": true, "released": true, "releaseDate": "2011-06-21" }, { "id": "11570", "description": "", "name": "Release 1.7.2", "archived": true, "released": true, "releaseDate": "2011-07-21" } ], "issuelinks": [ { "id": "12472", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "79410", "key": "TIMOB-5043", "fields": { "summary": "Make second argument of removeEventListener() optional rather than mandatory (Android and iOS)", "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" } }, "priority": { "name": "Low", "id": "4" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-13T17:51:50.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": "10202", "name": "Android", "description": "Android Platform" } ], "description": "The following code demonstrates that removeEventListener() does not remove an event listener for an event attached to a window or {{Ti.App}}:\r\n\r\n{code:lang=javascript|title=app.js}\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor: '#000',\r\n\texitOnClose:true\r\n});\r\n\r\nvar button = Ti.UI.createButton({\r\n\ttitle: 'Click to log events!',\r\n\theight:80,\r\n\twidth: 300\r\n});\r\n\r\nwin.add(button);\r\nwin.open();\r\n\r\nbutton.addEventListener('click', function(){\r\n\tTi.API.info('Button click event fired');\r\n\twin.fireEvent('testWinEvent');\r\n\tTi.App.fireEvent('testTiAppEvent');\r\n});\r\n\r\nwin.addEventListener('testWinEvent', function(){\r\n\tTi.API.info('testWinEvent event fired');\r\n});\r\nTi.App.addEventListener('testTiAppEvent', function(){\r\n\tTi.API.info('testTiAppEvent event fired');\r\n});\r\nwin.removeEventListener('testWinEvent',function(){});\r\nTi.App.removeEventListener('testTiAppEvent',function(){});\r\n{code}\r\n\r\nThe following is output to the console for all Titanium SDK versions tested:\r\n\r\n{code}\r\nI/TiAPI ( 598): (kroll$1: app://app.js) [177836,179502] Button click event fired\r\nI/TiAPI ( 598): (kroll$1: app://app.js) [3,179505] testWinEvent event fired\r\nI/TiAPI ( 598): (kroll$1: app://app.js) [0,179505] testTiAppEvent event fired\r\n{code}\r\n\r\nNote that no exception is generated.", "attachment": [], "flagged": false, "summary": "removeEventListener() method does not remove event listener", "creator": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "subtasks": [], "reporter": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "environment": "* emulator\r\n* Titanium SDK\r\n** 1.7.1 (2011/06/17 00:13 293a6d...)\r\n** 1.7.2 (2011/07/21 09:36 97c3689)\r\n** 1.7.3 (2011/08/05 10:18 )\r\n** 1.8.0 (2011/05/13 11:54 88c1b4...)\r\n* Android 2.1-update1\r\n* Titanium Studio, build: 1.0.4.201108101535, jenkins-titanium-rcp-master-40 (origin/master), 10 August 2011, 15:39:05\r\n* Ubuntu", "comment": { "comments": [ { "id": "163308", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "I have realised this ticket is invalid, so am closing. As one event can have multiple event handlers, it is necessary to provide a reference to the function that you intend to remove. Hence, the code beneath works. I will raise a ticket to request improvement to docs.\n\n{code:lang=javascript}\nvar win = Ti.UI.createWindow({\n\tbackgroundColor: '#000',\n\texitOnClose:true\n});\n\nvar button = Ti.UI.createButton({\n\ttitle: 'Click to log events!',\n\theight:80,\n\twidth: 300\n});\n\nwin.add(button);\nwin.open();\n\nbutton.addEventListener('click', function(){\n\tTi.API.info('Button click event fired');\n\twin.fireEvent('testWinEvent');\n\tTi.App.fireEvent('testTiAppEvent');\n});\n\nvar testWinEventHandler = function(){\n\tTi.API.info('testWinEvent event fired');\n};\n\nvar testTiAppEventHandler = function(){\n\tTi.API.info('testTiAppEvent event fired');\n};\n\nwin.addEventListener('testWinEvent', testWinEventHandler);\nTi.App.addEventListener('testTiAppEvent', testTiAppEventHandler);\n\nwin.removeEventListener('testWinEvent', testWinEventHandler);\nTi.App.removeEventListener('testTiAppEvent',testTiAppEventHandler);\n\n{code}", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-08-18T07:02:40.000+0000", "updated": "2011-08-18T07:02:40.000+0000" }, { "id": "411426", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as invalid.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-13T17:51:50.000+0000", "updated": "2017-03-13T17:51:50.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }