{ "id": "175996", "key": "AC-6667", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": null, "resolutiondate": null, "created": "2021-01-26T15:00:01.000+0000", "labels": [ "ios" ], "versions": [], "issuelinks": [], "assignee": { "name": "topener", "key": "topener", "displayName": "Rene Pot", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2021-01-27T16:46:52.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "The removeEventListener should only remove a callback function that was previously added, but on iOS it removes any one with the same event type, see test case below.\r\n\r\n{code}\r\nconst win=Ti.UI.createWindow({\r\n\tbackgroundColor:'#fff'\r\n});\r\nconst view=Ti.UI.createButton({\r\n\ttitle:'This button does nothing on OS...'\r\n});\r\nview.addEventListener('click',()=>{\r\n\talert('This alert does not open on iOS...')\r\n});\t\r\nview.removeEventListener('click',()=>{}); //This removes the callback added above, but it shouldn't!\r\nwin.add(view); \r\nwin.open();\r\n{code}", "attachment": [], "flagged": false, "summary": "iOS: removeEventListener removes \"any\" callback", "creator": { "name": "mj", "key": "mj", "displayName": "martin", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "mj", "key": "mj", "displayName": "martin", "active": true, "timeZone": "Europe/Berlin" }, "environment": "iOS Simulator, Ti SDK 9.3.0.GA", "comment": { "comments": [ { "id": "458087", "author": { "name": "topener", "key": "topener", "displayName": "Rene Pot", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hi, {{removeEventListener}} indeed removes events of the same type, otherwise, it would be impossible to remove anonymous callbacks. It is ALWAYS recommended to use named callbacks so you can prevent this yourself.", "updateAuthor": { "name": "topener", "key": "topener", "displayName": "Rene Pot", "active": true, "timeZone": "Europe/Berlin" }, "created": "2021-01-27T12:25:34.000+0000", "updated": "2021-01-27T12:25:34.000+0000" }, { "id": "458089", "author": { "name": "mj", "key": "mj", "displayName": "martin", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hi Rene,\r\nAnonymous functions are not the point here. You could change my example to use named callbacks and it will give the same result:\r\n{code}\r\nconst win=Ti.UI.createWindow({\r\n\tbackgroundColor:'#fff'\r\n});\r\nconst view=Ti.UI.createButton({\r\n\ttitle:'This button does nothing on OS...'\r\n});\r\nview.addEventListener('click',callback1);\t\r\nview.removeEventListener('click',callback2); //This removes the callback added above, but it shouldn't!\r\nwin.add(view); \r\nwin.open();\r\nfunction callback1() {\r\n\talert('This alert does not open on iOS...')\r\n}\r\nfunction callback2() {\t\r\n}\r\n{code}\r\nIf testing this on Android it will correctly show the alert when clicking the button. On iOS it will not.\r\n", "updateAuthor": { "name": "mj", "key": "mj", "displayName": "martin", "active": true, "timeZone": "Europe/Berlin" }, "created": "2021-01-27T12:44:17.000+0000", "updated": "2021-01-27T12:44:17.000+0000" }, { "id": "458096", "author": { "name": "topener", "key": "topener", "displayName": "Rene Pot", "active": true, "timeZone": "Europe/Berlin" }, "body": "Thanks for clarifying that, that wasn't clear from your original sample, there it actually behaved as expected. I will have a look at this one and get back to you!", "updateAuthor": { "name": "topener", "key": "topener", "displayName": "Rene Pot", "active": true, "timeZone": "Europe/Berlin" }, "created": "2021-01-27T16:46:34.000+0000", "updated": "2021-01-27T16:46:34.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }