$ scope. $ apply slows down performance
I have a single page application using AngularJS and I am facing one performance issue. My app handles inbound server side events that are passed to the client side AngularJS framework using ASP.NET SignalR. There are millions of events that can be received by my application and there are no performance issues on the server side and it easily passes this number of events one by one to the AngularJS framework. The problem lies with the client. After handling the event, I use $ scope. $ Apply () to update the page and display events. In this case, when multiple events are received one after the other, calling $ scope. $ Apply () slows down the application every time and doesn't show events quickly. Events will be relayed at random, so I don't even knowhow any events will be received by my application at any given time.
Any ideas on how to fix this issue would be very helpful.
source to share
From the docs:
Executes an expression in the current scope at a later point in time.
makes no guarantees as to when
- it will run after the function that scheduled the evaluation (preferably before the DOM is rendered).
- at least one loop
will be executed after execution
Any exceptions from the execution of the expression are sent to
Note: if this function is called outside of a loop
, a new Loop
will be scheduled. However, it is always recommended that the model changes from the call
. Which includes the code evaluated through
I also had a method
that was actually a rejected call
source to share