-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Why is the call to $apply needed in $http? #13108
Comments
Hey, this sounds about right. I would try replacing (This has been discussed before (more or less). See #2049 and #2049 (comment).) @thorn0, would fancy giving it a shot ? |
It won't work this way. The And please note that it's not the same issue as #2049 and #12557. It's more of a small performance refactoring. |
True. Yet, by merely removing So, I would still try replacing Again, this is off the top of my head, so take it with a grain of salt 😃 |
Or do you mean removing the Plus, replacing |
We can break someone's response interceptors this way.
No, I mean we can safely remove all these lines:
and leave only
|
How exactly ?
That would essentially remove the |
Those interceptors can modify the scopes (or other $watched values) and expect a digest to happen earlier than in the end of the interceptor chain.
No, we'll just get the same effect for free. |
OK, I'll believe you when I see it 😛 |
OK, please see this PR #13111. |
I think this issue is important in the first place because |
Is there a consideration that needs to be made for JavaScript to Native calls with regards to digest cycles? |
This `$apply` call was needed only for tests, so it's been moved to `$httpBackend.flush`. BREAKING CHANGE: `$httpProvider.useApplyAsync` has been removed. Closes angular#13108 Closes angular#13111
Closing, see: #13128 (comment) |
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
.The text was updated successfully, but these errors were encountered: