{"action":"created","issue":{"url":"https://api.github.com/repos/ractivejs/ractive/issues/2355","labels_url":"https://api.github.com/repos/ractivejs/ractive/issues/2355/labels{/name}","comments_url":"https://api.github.com/repos/ractivejs/ractive/issues/2355/comments","events_url":"https://api.github.com/repos/ractivejs/ractive/issues/2355/events","html_url":"https://github.com/ractivejs/ractive/issues/2355","id":128176637,"number":2355,"title":"Question: computed values within array","user":{"login":"dagnelies","id":5452653,"avatar_url":"https://avatars.githubusercontent.com/u/5452653?v=3","gravatar_id":"","url":"https://api.github.com/users/dagnelies","html_url":"https://github.com/dagnelies","followers_url":"https://api.github.com/users/dagnelies/followers","following_url":"https://api.github.com/users/dagnelies/following{/other_user}","gists_url":"https://api.github.com/users/dagnelies/gists{/gist_id}","starred_url":"https://api.github.com/users/dagnelies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dagnelies/subscriptions","organizations_url":"https://api.github.com/users/dagnelies/orgs","repos_url":"https://api.github.com/users/dagnelies/repos","events_url":"https://api.github.com/users/dagnelies/events{/privacy}","received_events_url":"https://api.github.com/users/dagnelies/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ractivejs/ractive/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/ractivejs/ractive/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-01-22T15:17:22Z","updated_at":"2016-01-22T16:47:14Z","closed_at":null,"body":"Hi,\r\n\r\nI got somewhat of a silly question, but I thought I'd ask nonetheless.\r\n\r\n**Intro**\r\n\r\nCurrently, my web page displays a list like this:\r\n\r\n| User   | Stuff                              | \r\n| --------|-------------------------------|\r\n| UserA | computed infos from A | \r\n| UserB | computed infos from B | \r\n| UserC | computed infos from C | \r\n\r\nWhere the left part is ``{{.username}}`` and the right part is a function computing something based on the user's data, like ``{{getInfos(.)}}``.\r\n\r\n**The \"annoyance\"**\r\n\r\nIn order to work, this `getInfos` is a function at the root of `data`. Since I'm also regularly fetching and sending this same `data` remotely, I always have to \"remove\" or \"add\" this `getInfos` function to the data. Which is kind of annoying.\r\n\r\nI guess there is no way to move this `getInfos` into `computed` properties, right? I mean, it would require either an argument, or be able to map a keypath within an array. Which is, as far as I know, not possible. Right?\r\n\r\nThe other possibility is to move every data item into a `real_data` prefix for example. It's OK, yet it doesn't feel as comfortable.\r\n\r\n**The question**\r\n\r\nJust in case I missed it: do you have a more comfortable way to compute something based on the data without altering the `data` object itself?\r\n\r\n*Extra note: moving it in a component isn't practical either because it also requires data outside the user itself.*\r\n"},"comment":{"url":"https://api.github.com/repos/ractivejs/ractive/issues/comments/173973946","html_url":"https://github.com/ractivejs/ractive/issues/2355#issuecomment-173973946","issue_url":"https://api.github.com/repos/ractivejs/ractive/issues/2355","id":173973946,"user":{"login":"evs-chris","id":161978,"avatar_url":"https://avatars.githubusercontent.com/u/161978?v=3","gravatar_id":"","url":"https://api.github.com/users/evs-chris","html_url":"https://github.com/evs-chris","followers_url":"https://api.github.com/users/evs-chris/followers","following_url":"https://api.github.com/users/evs-chris/following{/other_user}","gists_url":"https://api.github.com/users/evs-chris/gists{/gist_id}","starred_url":"https://api.github.com/users/evs-chris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evs-chris/subscriptions","organizations_url":"https://api.github.com/users/evs-chris/orgs","repos_url":"https://api.github.com/users/evs-chris/repos","events_url":"https://api.github.com/users/evs-chris/events{/privacy}","received_events_url":"https://api.github.com/users/evs-chris/received_events","type":"User","site_admin":false},"created_at":"2016-01-22T16:47:14Z","updated_at":"2016-01-22T16:47:14Z","body":"Looking at it, you could move `getInfos` to a computed property that just returns the function. If your transport back uses JSON, then the function would be stripped out automatically.\r\n\r\n```js\r\nnew Ractive({\r\n  el: '#somewhere',\r\n  template: '... getInfos(...) ...', // should pull the fn from computed and call it\r\n  data: { to: 'be replaced later' },\r\n  computed: {\r\n    getInfos(arrrrg) { return  do.stuffWith(arrrrg) }\r\n  },\r\n  shipData() {\r\n    send(JSON.stringify(this.get()));\r\n   }\r\n});\r\n```"}}