{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular.js/issues/13108","labels_url":"https://api.github.com/repos/angular/angular.js/issues/13108/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular.js/issues/13108/comments","events_url":"https://api.github.com/repos/angular/angular.js/issues/13108/events","html_url":"https://github.com/angular/angular.js/issues/13108","id":111741133,"number":13108,"title":"Why is the call to $apply needed in $http?","user":{"login":"thorn0","id":94334,"avatar_url":"https://avatars.githubusercontent.com/u/94334?v=3","gravatar_id":"","url":"https://api.github.com/users/thorn0","html_url":"https://github.com/thorn0","followers_url":"https://api.github.com/users/thorn0/followers","following_url":"https://api.github.com/users/thorn0/following{/other_user}","gists_url":"https://api.github.com/users/thorn0/gists{/gist_id}","starred_url":"https://api.github.com/users/thorn0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thorn0/subscriptions","organizations_url":"https://api.github.com/users/thorn0/orgs","repos_url":"https://api.github.com/users/thorn0/repos","events_url":"https://api.github.com/users/thorn0/events{/privacy}","received_events_url":"https://api.github.com/users/thorn0/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-10-16T01:41:09Z","updated_at":"2015-10-19T21:47:24Z","closed_at":null,"body":"I started to think about it looking at #12557. At first glance the answer is obvious: we need to update the views after we got a response, so we trigger a digest. But hey, it'll be triggered anyway because `$http` uses `$q` internally. And when a `$q` deferred is resolved, it schedules a digest. So can't we just remove that call to `$rootScope.$apply` (with all the `$applyAsync` thing altogether)? Am I missing something? If it's needed only for the tests, the `$apply` call should be moved to `$httpBackend.flush`."},"comment":{"url":"https://api.github.com/repos/angular/angular.js/issues/comments/149356905","html_url":"https://github.com/angular/angular.js/issues/13108#issuecomment-149356905","issue_url":"https://api.github.com/repos/angular/angular.js/issues/13108","id":149356905,"user":{"login":"thorn0","id":94334,"avatar_url":"https://avatars.githubusercontent.com/u/94334?v=3","gravatar_id":"","url":"https://api.github.com/users/thorn0","html_url":"https://github.com/thorn0","followers_url":"https://api.github.com/users/thorn0/followers","following_url":"https://api.github.com/users/thorn0/following{/other_user}","gists_url":"https://api.github.com/users/thorn0/gists{/gist_id}","starred_url":"https://api.github.com/users/thorn0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thorn0/subscriptions","organizations_url":"https://api.github.com/users/thorn0/orgs","repos_url":"https://api.github.com/users/thorn0/repos","events_url":"https://api.github.com/users/thorn0/events{/privacy}","received_events_url":"https://api.github.com/users/thorn0/received_events","type":"User","site_admin":false},"created_at":"2015-10-19T21:47:24Z","updated_at":"2015-10-19T21:47:24Z","body":"I think this issue is important in the first place because `$http` should be a model for building async services. It should be a canonical example of how async operations and the digest cycle should be married so that libraries like [bramski/angular-indexedDB](https://github.com/bramski/angular-indexedDB) could learn from it. But unfortunately, this example is misleading now. It leaves people wonder why it's written the way it is, why this `$apply` call can be needed."}}