javascript - Coalesce / defer multiple child scope $apply calls -
In my app, I'm getting data through an HTTP channel that is done in a custom way. I am making some [data] objects from the pipes, wrap them in a scope. $ New (true) and when I receive an updated call childScope. $ () Apply to set new properties.
It works well for light weight, all the informers are informed and actually running without any problems or mashed updates.
Now I am trying to push a lot of updates and do not know if the pattern is the way to use the above, I think (though not checked) that every call applies $ Are called digest in the area of the root and I want to collect it at the browser cycle or ~ 50 min intervals. Currently, whenever I get ~ 100 updates on 5000 objects / scope, it kills the browser.
I have noticed that Angel Docks says that the $ application of each scope has an AASC method, but I have not found it anywhere, it is essentially what will happen after I am.
Is this a bad idea and performance is already good enough? Should I implement my own applied asynchronous method using $ Browser.defer () or any other method?
Edit: The code was just tested and actually $ rootScope $ For each location is called Digest $ applied (). Perhaps it is better to take this part away from the angular JS and use the listener-based approach, so it's also a valid answer. Finally I used evalAsync and it seems to work as intended.
I probably need to call $ digest (or $ applicable) to make sure there are no pending changes but I have not yet seen the need to do this.
So my idea would be:
- Call for evalAsync for all scope changes that need to be very fast
- before evalAsync calls a Increasing the counter
- Set up a variable with the evalAsync function parameter at the current time and decrease the counter
- On the timer (50-100ms), see if the counter is & gt; 0 and if the final evaluation time was some time ago (> 50-100ms) and if yes, emphasize the digestive loop.
I do not mark it as a correct answer because it does not seem to be the best idea, but it is best I can come along and it does j .
Comments
Post a Comment