{ "id": "171188", "key": "TIMOB-25807", "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": "2018-03-21T10:00:52.000+0000", "created": "2018-02-24T19:05:01.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [], "versions": [ { "id": "19975", "name": "Hyperloop 3.1.0", "archived": false, "released": true } ], "issuelinks": [], "assignee": null, "updated": "2018-08-06T17:37:03.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": "13715", "name": "Hyperloop", "description": "Hyperloop project" } ], "description": "When using ES6 in Hyperloop methods, e.g. \r\n{code:js}\r\n var ButtonDelegate = Hyperloop.defineClass('ButtonDelegate', 'NSObject');\r\n\r\n ButtonDelegate.addMethod({\r\n selector: 'buttonPressed:',\r\n instance: true,\r\n arguments: ['UIButton'],\r\n callback: (sender) => { \r\n if (this.buttonPressed) {\r\n// ^-- Here is the issue - it cannot find the declared method\r\n this.buttonPressed(sender);\r\n }\r\n }\r\n });\r\n\r\n var delegate = new ButtonDelegate();\r\n\r\n // Not found when being used in \"Hyperloop.addMethod\"\r\n delegate.buttonPressed = function(sender) {\r\n alert('Button pressed!');\r\n };\r\n{code}\r\nthe {{this.buttonPressed}} method cannot be found, although declared. We use this pattern many times, to assign methods to instances afterwards. If there is a better approach, we should replace the usages in the hyperloop-examples sample app.\r\n\r\n*EDIT*: It only seems to be an issue if the delegate is in the same file as its usage. It works fine for other delegates / sub classes like [here|https://github.com/appcelerator/hyperloop-examples/blob/master/app/lib/ios/subclasses/tableviewdatasourcedelegate.js#L9].", "attachment": [], "flagged": false, "summary": "Hyperloop - ES6: Cannot find scoped \"this\" methods anymore", "creator": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "environment": null, "closedSprints": [ { "id": 1008, "state": "closed", "name": "2018 Sprint 06 SDK", "startDate": "2018-03-11T22:18:04.396Z", "endDate": "2018-03-25T22:18:00.000Z", "completeDate": "2018-03-25T21:52:36.683Z", "originBoardId": 216 } ], "comment": { "comments": [ { "id": "435458", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~cwilliams] Not sure if this is an SDK- or Hyperloop- or code-design-related issue.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-03-11T10:17:42.000+0000", "updated": "2018-03-11T10:17:42.000+0000" }, { "id": "435791", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Resolving as {{Invalid}} as ES6 arrow functions have a different scope. To solve this, simply use non-Arrow functions and make use of the global / file-wide {{this}} scope.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-03-21T10:00:52.000+0000", "updated": "2018-03-21T10:00:52.000+0000" }, { "id": "439929", "author": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing as invalid. If incorrect, please reopen.", "updateAuthor": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-08-06T17:37:03.000+0000", "updated": "2018-08-06T17:37:03.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }