{ "id": "173666", "key": "ALOY-1689", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false }, "project": { "id": "11113", "key": "ALOY", "name": "Alloy", "projectCategory": { "id": "10400", "description": "Tools for developing applications", "name": "Tooling" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2019-05-24T02:06:22.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "ListView", "TableView", "change", "data-binding", "events", "optimization", "remove" ], "versions": [], "issuelinks": [], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2019-05-24T02:44:47.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": "13605", "name": "Models" } ], "description": "*Summary:*\r\nWhen data-binding a model to a {{ListView}} or {{TableView}}, the model's \"change\" and \"remove\" events cause all of the rows to be removed and recreated. This is very expensive if the model collection is very large. This should be optimized so that if only 1 model has been changed, then we replace its 1 row in the UI instead. And if only 1 model has been removed, then delete its 1 row from the UI.\r\n\r\n*Recommended Solution:*\r\nWhen the Alloy generated code populates an array of rows to be added to the {{ListView}} or {{TableView}}, it should also set up a dictionary which maps the model IDs to their respective row indexes. We can then use this dictionary for fast lookup when a \"change\" or \"remove\" event happens.\r\n\r\n*Note:*\r\nWe cannot do the above optimization if a \"dataFilter\" has been assigned to the {{ListView}} or {{TableView}}. A \"dataFilter\" is a function that takes the source model array and returns a new array to be turned into rows in the UI. This \"dataFilter\" function is intended to be used to exclude elements (ex: a search filter) and/or sort elements. Since it's capable of sorting, we have to assume that a changed model needs to be repositioned in the UI. Unfortunately, this means preserving the old behavior where we destroy all rows and recreate them.\r\n", "attachment": [], "flagged": false, "summary": "Optimize model \"change\" and \"remove\" data-binding with ListView/TableView", "creator": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [], "maxResults": 0, "total": 0, "startAt": 0 } } }