3 ms·
There seems to be a lot of magic going on under the hood, which will help you get off the ground quickly but I worry how easy it is to extend this to do unusual
by glenjamin 14y ago
There seems to be a lot of magic going on under the hood, which will help you get off the ground quickly but I worry how easy it is to extend this to do unusual things.
Likewise, to provide features like dynamic update when a function's return value changes I assume it has to do either something very clever, or something very dumb (polling?). How performant is this sort of approach?
- patrickaljord 14y agoThis is how they do it http://stackoverflow.com/questions/9682092/databinding-in-angularjs http://stackoverflow.com/questions/9682092/databinding-in-an...
- mhansen 14y agoYes, it polls. Most functions are quite fast, and fine to just poll, and it's quite convenient to be able to bind to functions when needed. But it's all tradeoffs - in our app we have a few that aren't - for those, we profiled to find them, and added a bit of code to the functions to cache the return value.
- atjoslin 14y agoIt doesn't poll, actually.
- mhansen 14y agoSorry, what I meant is that when the application rerenders (digesting changes that have been made) it will re-evaluate the function to check if the result has changed. Polling the function for changes, contrast with how e.g. knockout.js pushes changes. (I could be wrong, please let me know if my understanding's not reality)
- atjoslin 14y agoAh, yeah I think you've got it right. I thought you meant polling as in it checked every X milliseconds for changes.
- vojtajina 14y agoI wouldn't call it polling. Angular does dirty checking at the right moment. After you bootstrap your app, nothing happens, unless: - user interacts (DOM event is fired) - response from server is back (xhr callback) - setTimeout fires - couple of other minor async stuff So you only need to dirty check when some of these events occur and that's exactly what Angular does. Check out scope.$digest method, that's where all this stuff happens.