nr: #1 dodano: 2017-01-04 09:01
Probably doesn't make a huge difference with a smaller app - by the sounds of things
useApplyAsync will delay processing by ~10ms but aggregates processing of responses so may be slightly faster if say multiple responses come in within that window it might allow them to share a digest cycle avoiding extra overheads.
The default behavior processes each individual response more quickly (I think synchronously) but might require more digest cycles if multiple responses are received in quick succession which might require more processing and hence be slower overall.
So short answer
useApplyAsync is probably faster with many rapid requests that update a lot of data, the default behavior is probably faster with less frequent requests.
I'd guess that it's disabled by default as usually if you're firing off that many AJAX requests you probably need to rethink your API (ie provide options for consolidating the requests).
Advantages of enabling useApplyAsync
If multiple responses are received in short succession it might reduce the amount of digest cycles required
Disadvantages of enabling useApplyAsync
It may delay processing of a response by ~10ms whilst waiting to aggregate processing
Why is it disabled by default?
Delaying processing of most AJAX requests by ~10ms for a short window to attempt to process multiple responses concurrently and avoid additional digest cycles is for most use cases less desirable than the few additional digest cycles it might save by enabling it.
The relevant docs have more info
"Configure $http service to combine processing of multiple http
responses received at around the same time via $rootScope.$applyAsync.
This can result in significant performance improvement for bigger
applications that make many HTTP requests concurrently (common during
Schedule the invocation of $apply to occur at a later time. The actual
time difference varies across browsers, but is typically around ~10
$apply() is used to execute an expression in angular from outside of the angular framework. (For example from browser DOM events, setTimeout, XHR or third party libraries). Because we are calling into the angular framework we need to perform proper scope life cycle of exception handling, executing watches.