{"action":"closed","issue":{"url":"https://api.github.com/repos/aurelia/binding/issues/195","labels_url":"https://api.github.com/repos/aurelia/binding/issues/195/labels{/name}","comments_url":"https://api.github.com/repos/aurelia/binding/issues/195/comments","events_url":"https://api.github.com/repos/aurelia/binding/issues/195/events","html_url":"https://github.com/aurelia/binding/issues/195","id":112892403,"number":195,"title":"Suggestion: optimized observable arrays","user":{"login":"jods4","id":3832820,"avatar_url":"https://avatars.githubusercontent.com/u/3832820?v=3","gravatar_id":"","url":"https://api.github.com/users/jods4","html_url":"https://github.com/jods4","followers_url":"https://api.github.com/users/jods4/followers","following_url":"https://api.github.com/users/jods4/following{/other_user}","gists_url":"https://api.github.com/users/jods4/gists{/gist_id}","starred_url":"https://api.github.com/users/jods4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jods4/subscriptions","organizations_url":"https://api.github.com/users/jods4/orgs","repos_url":"https://api.github.com/users/jods4/repos","events_url":"https://api.github.com/users/jods4/events{/privacy}","received_events_url":"https://api.github.com/users/jods4/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-22T21:10:44Z","updated_at":"2015-11-12T05:11:15Z","closed_at":"2015-11-12T05:11:15Z","body":"Knockout had this and it was awesome and useful: http://github.com/SteveSanderson/knockout-projections.\r\n\r\nBasically: some operations on arrays are very common (e.g. filtering `.filter()` or projecting `.map()`).\r\nConsider how you would display a filtered list in Aurelia today:\r\n```typescript\r\n@computedFrom([\"search\", \"items[]\"])\r\nget filteredItems() { return this.items.filter(x => x.name === this.search); }\r\n```\r\nThis works (except for the array observation, see #194) but any time one item is added, the whole array is filtered and copied again, and then the DOM is entirely rebuilt.\r\n\r\nKO.projections has \"intelligent\" array operations. When an item is added to `items` a change notification is received by the filtered array. It then looks at the new element and checks if it satisfies the predicate. If no, nothing is done. If yes, it is added to the filtered collection and a change notification is raised.\r\n\r\nThis means that for stuff like projections or filtering, adding/removing an element is O(1) instead of O(N)."}}