{"action":"created","issue":{"url":"https://api.github.com/repos/Urigo/angular-meteor/issues/742","labels_url":"https://api.github.com/repos/Urigo/angular-meteor/issues/742/labels{/name}","comments_url":"https://api.github.com/repos/Urigo/angular-meteor/issues/742/comments","events_url":"https://api.github.com/repos/Urigo/angular-meteor/issues/742/events","html_url":"https://github.com/Urigo/angular-meteor/issues/742","id":110046147,"number":742,"title":"$rootScope.currentUser is not acting like a Reactive Data Source","user":{"login":"Svenskunganka","id":2657513,"avatar_url":"https://avatars.githubusercontent.com/u/2657513?v=3","gravatar_id":"","url":"https://api.github.com/users/Svenskunganka","html_url":"https://github.com/Svenskunganka","followers_url":"https://api.github.com/users/Svenskunganka/followers","following_url":"https://api.github.com/users/Svenskunganka/following{/other_user}","gists_url":"https://api.github.com/users/Svenskunganka/gists{/gist_id}","starred_url":"https://api.github.com/users/Svenskunganka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Svenskunganka/subscriptions","organizations_url":"https://api.github.com/users/Svenskunganka/orgs","repos_url":"https://api.github.com/users/Svenskunganka/repos","events_url":"https://api.github.com/users/Svenskunganka/events{/privacy}","received_events_url":"https://api.github.com/users/Svenskunganka/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-06T16:18:24Z","updated_at":"2015-10-06T17:07:56Z","closed_at":null,"body":"Hey!\r\n\r\nI've got this code:\r\n\r\n```Javascript\r\n$scope.$meteorAutorun(function() {\r\n    if ($rootScope.currentUser.completedGuides &&\r\n        $rootScope.currentUser.completedGuides.indexOf($scope.guide._id) > -1) {\r\n      $scope.isChecked = true;\r\n    } else {\r\n      $scope.isChecked = false;\r\n    }\r\n  });\r\n```\r\n\r\nBut the `$rootScope.currentUser` variable is not re-running the function when it updates as I have this code in Meteor:\r\n\r\n```Javascript\r\nMeteor.publish('userData', function() {\r\n  if (this.userId) {\r\n    return Meteor.users.find({ _id: this.userId }, { fields: { completedGuides: 1 } });\r\n  } else {\r\n    this.ready();\r\n  }\r\n});\r\n```\r\nand this code in a `.run` function in my app:\r\n```Javascript\r\nangular.module('myApp')\r\n.run(['$meteor', function($meteor) {\r\n  $meteor.subscribe('userData');\r\n}]);\r\n```\r\n\r\nIf I create a never ending loop with a 1 second wait, I can see that after one second or so the `completedGuides` property shows up in the `$rootScope.currentUser` object, but the `$scope.$meteorAutorun` function is not being re-run.\r\n\r\nLooking at [angular-meteor-user.js#L79](https://github.com/Urigo/angular-meteor/blob/master/modules/angular-meteor-user.js#L79) I can see that the `$rootScope.currentUser` is simply a replicate of `Meteor.user()`, and above that line I can also see that the autorun function is bound to the `$rootScope` scope. I've tried replacing my `$scope.meteorAutorun(fn)` with `$meteor.autorun($rootScope, fn)` without success.\r\n\r\nAny clues why this is happening or do I have some code issues?"},"comment":{"url":"https://api.github.com/repos/Urigo/angular-meteor/issues/comments/145929758","html_url":"https://github.com/Urigo/angular-meteor/issues/742#issuecomment-145929758","issue_url":"https://api.github.com/repos/Urigo/angular-meteor/issues/742","id":145929758,"user":{"login":"mxab","id":1607547,"avatar_url":"https://avatars.githubusercontent.com/u/1607547?v=3","gravatar_id":"","url":"https://api.github.com/users/mxab","html_url":"https://github.com/mxab","followers_url":"https://api.github.com/users/mxab/followers","following_url":"https://api.github.com/users/mxab/following{/other_user}","gists_url":"https://api.github.com/users/mxab/gists{/gist_id}","starred_url":"https://api.github.com/users/mxab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mxab/subscriptions","organizations_url":"https://api.github.com/users/mxab/orgs","repos_url":"https://api.github.com/users/mxab/repos","events_url":"https://api.github.com/users/mxab/events{/privacy}","received_events_url":"https://api.github.com/users/mxab/received_events","type":"User","site_admin":false},"created_at":"2015-10-06T17:07:56Z","updated_at":"2015-10-06T17:07:56Z","body":"You should use Meteor.user() for your use case.\r\n```\r\n$scope.$meteorAutorun(function() {\r\nvar currentUser = Meteor.user();\r\n    if (currentUser.completedGuides &&\r\n        currentUser.completedGuides.indexOf($scope.guide._id) > -1) {\r\n      $scope.isChecked = true;\r\n    } else {\r\n      $scope.isChecked = false;\r\n    }\r\n  });\r\n```\r\n\r\nThere is no way the autorun could detect that you are accessing a property."}}