{"action":"created","issue":{"url":"https://api.github.com/repos/mweststrate/mobservable/issues/50","labels_url":"https://api.github.com/repos/mweststrate/mobservable/issues/50/labels{/name}","comments_url":"https://api.github.com/repos/mweststrate/mobservable/issues/50/comments","events_url":"https://api.github.com/repos/mweststrate/mobservable/issues/50/events","html_url":"https://github.com/mweststrate/mobservable/issues/50","id":116866883,"number":50,"title":"Computeds aren't evaluated before renders after a transaction.","user":{"login":"dzearing","id":1110944,"avatar_url":"https://avatars.githubusercontent.com/u/1110944?v=3","gravatar_id":"","url":"https://api.github.com/users/dzearing","html_url":"https://github.com/dzearing","followers_url":"https://api.github.com/users/dzearing/followers","following_url":"https://api.github.com/users/dzearing/following{/other_user}","gists_url":"https://api.github.com/users/dzearing/gists{/gist_id}","starred_url":"https://api.github.com/users/dzearing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzearing/subscriptions","organizations_url":"https://api.github.com/users/dzearing/orgs","repos_url":"https://api.github.com/users/dzearing/repos","events_url":"https://api.github.com/users/dzearing/events{/privacy}","received_events_url":"https://api.github.com/users/dzearing/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-11-13T22:33:00Z","updated_at":"2015-11-13T23:07:26Z","closed_at":null,"body":"Take this computed example:\r\n\r\n```typescript\r\n@obervable a = true;\r\n@obervable b = false;\r\n\r\n@observable get c() {\r\n  return  `C thinks that the b value is: ${ b }`;\r\n}\r\n```\r\n\r\nI have a react component `@observer` which renders a b and c.\r\n\r\nI mutate them in a transaction:\r\n\r\n```typescript\r\ntransaction(() => {\r\n   this.a = !this.a;\r\n   this.b = !this.b;\r\n}\r\n```\r\n\r\nExpected after the transaction is complete:\r\n\r\nc is evaluated (all computed values should be evaluated before a single render is executed)\r\nrender is called (rendering the updated c value)\r\n\r\nResulted:\r\n\r\nrender is called (rendering old version of c)\r\nc is evaluated with no followup render\r\n\r\nExplanation:\r\n\r\nMutating \"a\" causes the \"render\" observer to enqueue first.\r\nMutating \"b\" causes the computed observer to enqueue second.\r\nIt is a bug that the computed isn't resolved first, but even with the bug, I would have expected the render to be called twice.\r\n\r\nIf you flip the order of mutations, the issue is resolved. But this is a pretty nasty issue. The right thing to do here is to resolve all non-ui dependencies first, and then update any unique component observers that need updating second.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/mweststrate/mobservable/issues/comments/156583963","html_url":"https://github.com/mweststrate/mobservable/issues/50#issuecomment-156583963","issue_url":"https://api.github.com/repos/mweststrate/mobservable/issues/50","id":156583963,"user":{"login":"dzearing","id":1110944,"avatar_url":"https://avatars.githubusercontent.com/u/1110944?v=3","gravatar_id":"","url":"https://api.github.com/users/dzearing","html_url":"https://github.com/dzearing","followers_url":"https://api.github.com/users/dzearing/followers","following_url":"https://api.github.com/users/dzearing/following{/other_user}","gists_url":"https://api.github.com/users/dzearing/gists{/gist_id}","starred_url":"https://api.github.com/users/dzearing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzearing/subscriptions","organizations_url":"https://api.github.com/users/dzearing/orgs","repos_url":"https://api.github.com/users/dzearing/repos","events_url":"https://api.github.com/users/dzearing/events{/privacy}","received_events_url":"https://api.github.com/users/dzearing/received_events","type":"User","site_admin":false},"created_at":"2015-11-13T23:07:26Z","updated_at":"2015-11-13T23:07:26Z","body":"looks like it :)\r\n\r\nI updated it here, and here's some weirdness:\r\n\r\nThe timeout does the wrong thing\r\nThe button click does the right thing\r\n\r\nWhat's different?\r\n\r\nhttp://jsfiddle.net/L0kd41hj/5/\r\n"}}