{"action":"created","issue":{"url":"https://api.github.com/repos/BorisMoore/jsviews/issues/334","repository_url":"https://api.github.com/repos/BorisMoore/jsviews","labels_url":"https://api.github.com/repos/BorisMoore/jsviews/issues/334/labels{/name}","comments_url":"https://api.github.com/repos/BorisMoore/jsviews/issues/334/comments","events_url":"https://api.github.com/repos/BorisMoore/jsviews/issues/334/events","html_url":"https://github.com/BorisMoore/jsviews/issues/334","id":137606014,"number":334,"title":"Stack overflow using .depends function with computed observable","user":{"login":"Paul-Martin","id":3865109,"avatar_url":"https://avatars.githubusercontent.com/u/3865109?v=3","gravatar_id":"","url":"https://api.github.com/users/Paul-Martin","html_url":"https://github.com/Paul-Martin","followers_url":"https://api.github.com/users/Paul-Martin/followers","following_url":"https://api.github.com/users/Paul-Martin/following{/other_user}","gists_url":"https://api.github.com/users/Paul-Martin/gists{/gist_id}","starred_url":"https://api.github.com/users/Paul-Martin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Paul-Martin/subscriptions","organizations_url":"https://api.github.com/users/Paul-Martin/orgs","repos_url":"https://api.github.com/users/Paul-Martin/repos","events_url":"https://api.github.com/users/Paul-Martin/events{/privacy}","received_events_url":"https://api.github.com/users/Paul-Martin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-01T15:34:36Z","updated_at":"2016-03-03T00:53:38Z","closed_at":null,"body":"Hello Boris,\r\n\r\nI've run into what appears to be a regression when using .depends functions with computed observables.  In this case I am using them to create context sensitive menus that change based on the selected item.  This jsfiddle reproduces the issue.  \r\n\r\nhttps://jsfiddle.net/PaulMartin/d51emo1x/\r\n\r\nIn short if I use this syntax the stack is blown:\r\n```\r\nControlBarAction.prototype.enabled.depends = function() {\r\n    // !!!! This produces stack overflow !!!!\r\n    return [this, 'selected', this.selected(), 'enabled'];\r\n};\t\t\r\n    // !!!! This does not \r\n    return [this, 'selected', 'selected.enabled'];\r\n};\r\n```\r\nbut if I use this syntax (which I believe to be functionally equivalent) it is not\r\n```\r\nControlBarAction.prototype.enabled.depends = function() {\r\n    // !!!! This does not \r\n    return [this, 'selected', 'selected.enabled'];\r\n    // !!!! Nor does this\r\n    return [this, 'selected', 'selected^enabled'];\r\n};\t\t\r\n```\r\nIn the fiddle, you can just comment / uncomment to see the stack overflow.\r\n\r\nI had been using the first syntax for quite some time and upgraded to the latest version from 64 yesterday when I encountered this issue.  Judging from the change logs, I would guess the enhancements made in commit 72 introduced this issue.\r\n\r\nPlease let me know if I can provide you any additional information.\r\n"},"comment":{"url":"https://api.github.com/repos/BorisMoore/jsviews/issues/comments/191516135","html_url":"https://github.com/BorisMoore/jsviews/issues/334#issuecomment-191516135","issue_url":"https://api.github.com/repos/BorisMoore/jsviews/issues/334","id":191516135,"user":{"login":"Paul-Martin","id":3865109,"avatar_url":"https://avatars.githubusercontent.com/u/3865109?v=3","gravatar_id":"","url":"https://api.github.com/users/Paul-Martin","html_url":"https://github.com/Paul-Martin","followers_url":"https://api.github.com/users/Paul-Martin/followers","following_url":"https://api.github.com/users/Paul-Martin/following{/other_user}","gists_url":"https://api.github.com/users/Paul-Martin/gists{/gist_id}","starred_url":"https://api.github.com/users/Paul-Martin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Paul-Martin/subscriptions","organizations_url":"https://api.github.com/users/Paul-Martin/orgs","repos_url":"https://api.github.com/users/Paul-Martin/repos","events_url":"https://api.github.com/users/Paul-Martin/events{/privacy}","received_events_url":"https://api.github.com/users/Paul-Martin/received_events","type":"User","site_admin":false},"created_at":"2016-03-03T00:53:38Z","updated_at":"2016-03-03T00:53:38Z","body":"Wow. Amazing!  Thanks for the explanation Boris. \n\n\n\n> On Mar 2, 2016, at 7:14 PM, Boris Moore <notifications@github.com> wrote:\n> \n> Simply setting xxx.depends = [\"selected^enabled\"] is the right way to do that scenario. (Even if selected is set later.)\n> \n> xxx.depends = [\"selected.enabled\"] or xxx.depends = function() {return [this.selected(), \"enabled\"]} will be equivalent - and in both cases the depends expression is evaluated once (during template linking) and will not re-evaluate after a change in selected - so there will not be a listener for changes to the enabled property of the new selected. Even depends = [\"selected\", \"selected.enabled\"] will only listen to changes to the \"selected\" and to the initial selected.enabled. - Whereas \"selected^enabled\"` will do it all!\n> \n> —\n> Reply to this email directly or view it on GitHub.\n> \n"}}