{"action":"created","issue":{"url":"https://api.github.com/repos/aurelia/framework/issues/147","labels_url":"https://api.github.com/repos/aurelia/framework/issues/147/labels{/name}","comments_url":"https://api.github.com/repos/aurelia/framework/issues/147/comments","events_url":"https://api.github.com/repos/aurelia/framework/issues/147/events","html_url":"https://github.com/aurelia/framework/issues/147","id":92019275,"number":147,"title":"Knowing if a property is a computed or observable?","user":{"login":"grofit","id":927201,"avatar_url":"https://avatars.githubusercontent.com/u/927201?v=3","gravatar_id":"","url":"https://api.github.com/users/grofit","html_url":"https://github.com/grofit","followers_url":"https://api.github.com/users/grofit/followers","following_url":"https://api.github.com/users/grofit/following{/other_user}","gists_url":"https://api.github.com/users/grofit/gists{/gist_id}","starred_url":"https://api.github.com/users/grofit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grofit/subscriptions","organizations_url":"https://api.github.com/users/grofit/orgs","repos_url":"https://api.github.com/users/grofit/repos","events_url":"https://api.github.com/users/grofit/events{/privacy}","received_events_url":"https://api.github.com/users/grofit/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-30T07:57:47Z","updated_at":"2015-06-30T08:20:12Z","closed_at":null,"body":"Coming from the knockout world you have the following functions `ko.isObservable(someProperty)` and `ko.isComputed(someProperty)`. So you can find out if a property of a model is an observable or a computed property (they also have one for observable arrays I think).\r\n\r\nI appreciate that in knockout properties are actually knockout observable types so it is far easier for them to check if it is an observable or a computed, however I have a scenario currently where I am traversing a model and need to subscribe to any observables within there, however I cannot find a way to leave out any computed properties. Currently I am just assuming all objects are implicitly observable, but I know this will give me headaches in the long run.\r\n\r\nIt was mentioned in the gitter that there may be some way to do it with the `observerLocator` (which I am currently trying to use for subscribing to observables), but they (@Aaike) were unsure if it was possible currently.\r\n\r\nSo could this be thought of as a nice to have? "},"comment":{"url":"https://api.github.com/repos/aurelia/framework/issues/comments/117052104","html_url":"https://github.com/aurelia/framework/issues/147#issuecomment-117052104","issue_url":"https://api.github.com/repos/aurelia/framework/issues/147","id":117052104,"user":{"login":"zewa666","id":2861414,"avatar_url":"https://avatars.githubusercontent.com/u/2861414?v=3","gravatar_id":"","url":"https://api.github.com/users/zewa666","html_url":"https://github.com/zewa666","followers_url":"https://api.github.com/users/zewa666/followers","following_url":"https://api.github.com/users/zewa666/following{/other_user}","gists_url":"https://api.github.com/users/zewa666/gists{/gist_id}","starred_url":"https://api.github.com/users/zewa666/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zewa666/subscriptions","organizations_url":"https://api.github.com/users/zewa666/orgs","repos_url":"https://api.github.com/users/zewa666/repos","events_url":"https://api.github.com/users/zewa666/events{/privacy}","received_events_url":"https://api.github.com/users/zewa666/received_events","type":"User","site_admin":false},"created_at":"2015-06-30T08:20:12Z","updated_at":"2015-06-30T08:20:12Z","body":"Computed properties are expressed as JavaScript getters. Thus in order to find out whether a thing is a property you can leverage `Object.getOwnPropertyDescriptor`.\r\n\r\nIn case of the welcome page in the skeleton navigation app you could do following:\r\n\r\n```\r\nconstructor() {\r\n  var x = Object.getOwnPropertyDescriptor(Welcome.prototype, 'fullName');\r\n  console.log(x);\r\n}\r\n```\r\n\r\nwhich results in an object like:\r\n```\r\n{ configurable: true, enumerable: true, get: /*the getter function*/, set: undefined }\r\n```\r\n\r\nnow all you need is to iterate over all props and check for the getter. Now as for the task of listening or getting a list of changes might have a look at the Contacts App's https://github.com/aurelia/app-contacts/blob/master/src/contact-detail.js\r\n\r\nThere we simply store a JSON stringified version at the begin and check it later with the end-version to determine whether there are changes."}}