{"action":"created","issue":{"url":"https://api.github.com/repos/meteor/meteor/issues/5396","labels_url":"https://api.github.com/repos/meteor/meteor/issues/5396/labels{/name}","comments_url":"https://api.github.com/repos/meteor/meteor/issues/5396/comments","events_url":"https://api.github.com/repos/meteor/meteor/issues/5396/events","html_url":"https://github.com/meteor/meteor/issues/5396","id":110548732,"number":5396,"title":"Unexpected order of onInvalidate callbacks","user":{"login":"mitar","id":585279,"avatar_url":"https://avatars.githubusercontent.com/u/585279?v=3","gravatar_id":"","url":"https://api.github.com/users/mitar","html_url":"https://github.com/mitar","followers_url":"https://api.github.com/users/mitar/followers","following_url":"https://api.github.com/users/mitar/following{/other_user}","gists_url":"https://api.github.com/users/mitar/gists{/gist_id}","starred_url":"https://api.github.com/users/mitar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitar/subscriptions","organizations_url":"https://api.github.com/users/mitar/orgs","repos_url":"https://api.github.com/users/mitar/repos","events_url":"https://api.github.com/users/mitar/events{/privacy}","received_events_url":"https://api.github.com/users/mitar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-08T21:53:46Z","updated_at":"2015-10-11T12:39:31Z","closed_at":null,"body":"If an `onInvalidate` callback function calls `onInvalidate` by itself, the function is immediately called.\r\n\r\nSo for code something like this:\r\n\r\n```javascript\r\nvar c = Tracker.autorun(function () {});\r\nc.onInvalidate(function () {\r\n  console.log(\"a\");\r\n  c.onInvalidate(function () {\r\n    console.log(\"d\");\r\n  });\r\n  console.log(\"b\");\r\n});\r\nc.onInvalidate(function () {\r\n  console.log(\"c\");\r\n});\r\nc.invalidate();\r\n```\r\n\r\nPrints: adbc\r\n\r\nWhen one would expect: abcd\r\n\r\nThe `onInvalidate` callbacks should be called in the order they were registered, no?"},"comment":{"url":"https://api.github.com/repos/meteor/meteor/issues/comments/147189246","html_url":"https://github.com/meteor/meteor/issues/5396#issuecomment-147189246","issue_url":"https://api.github.com/repos/meteor/meteor/issues/5396","id":147189246,"user":{"login":"zimme","id":1215414,"avatar_url":"https://avatars.githubusercontent.com/u/1215414?v=3","gravatar_id":"","url":"https://api.github.com/users/zimme","html_url":"https://github.com/zimme","followers_url":"https://api.github.com/users/zimme/followers","following_url":"https://api.github.com/users/zimme/following{/other_user}","gists_url":"https://api.github.com/users/zimme/gists{/gist_id}","starred_url":"https://api.github.com/users/zimme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zimme/subscriptions","organizations_url":"https://api.github.com/users/zimme/orgs","repos_url":"https://api.github.com/users/zimme/repos","events_url":"https://api.github.com/users/zimme/events{/privacy}","received_events_url":"https://api.github.com/users/zimme/received_events","type":"User","site_admin":false},"created_at":"2015-10-11T12:39:31Z","updated_at":"2015-10-11T12:39:31Z","body":"@mitar Here's a part of the `onInvalidate` docs\r\n>, or runs it immediately if the computation is already invalidated.\r\n\r\nWhich leads me to expect the current behaviour."}}