4 ms·
Then you should really look more into how angularjs works. The whole thing works so beautiful because there's a global digestion cycle which captures all the ch
by SchizoDuckie 13y ago
Then you should really look more into how angularjs works.
The whole thing works so beautiful because there's a global digestion cycle which captures all the changed events within one 'loop', processes the changes, and then kicks off the next cycle, like with a game's heartbeat.
Also, the way you need to set up things with angular makes sure this works perfectly. you need to work with models, controllers, services and directives, which all have a well thought out way of accessing, watching and broadcasting changes.
Things start to break when you start using jquery and just randomly do shit with the DOM outside of angular's scope, but that's one of the reasons why i'm rewriting stuff to work without jquery.
I think angular is the best way forward for the web since the invention of XHR requests actually.
- latchkey 13y agoI can't agree more. I'm just now rewriting a portion of my webapp to be a single page app using angular. I'm blown away at how it simple it is to do some really complicated stuff. This is entirely the result of how it forces me to properly organize my code. For example, when I open up a bootstrap tooltip/popover, I wanted to disable all the buttons on the page. It was as simple as invalidating the ng-form and this just works across many directives and modules (assuming you pass the form through the scope). Doing this the old way with jquery would have been a nightmare. At first I resisted the templates. I kept trying to use Handlebars to render things cause that is what I was used to. Then I realized that the 2 way data binding (ng-repeat with track by) is just magical. I can take a json blob received from an ajax call and set that on a property on the scope. My template just magically updates only the dom elements that changed. By the way, coffeescript is perfect for the templates because you can just embed them in """ ... """ blocks. My code is also now organized so much more cleanly. The way directive components are organized forces me to think about reuse. It makes it so much easier to see the dependencies between things and create distinct levels of separation. This allows you to make components that can be moved around easily in case you change the flow of your application or just want to display something on another screen. My buddy and I came up with a way of taking large cyclical object graph blobs of json and de-duplicating the objects for transfer over the wire. This ends up working perfectly with the aforementioned data binding to minimize the amount of json on the wire, while still retaining our complete object model. https://github.com/jsog/jsog https://github.com/jsog/jsog I'm kicking myself for not picking this up earlier.
- SchizoDuckie 13y agoAlso : Angular.element is really powerful. I'm using it in my chrome extension to parse both RSS and HTML and return objects. Services are an amazing way of working. The web is really my API now. https://github.com/SchizoDuckie/seriesguide-chrome/blob/angular/js/seriesguide.torrentfreak.js https://github.com/SchizoDuckie/seriesguide-chrome/blob/angu... https://github.com/SchizoDuckie/seriesguide-chrome/blob/angular/js/seriesguide.thepiratebay.js https://github.com/SchizoDuckie/seriesguide-chrome/blob/angu... (See it in action in a chrome extension: https://chrome.google.com/webstore/detail/seriesguide-chrome-v2-bro/cdfkaloficjmdjbgmckaddgfcghgidei https://chrome.google.com/webstore/detail/seriesguide-chrome... )
- caitp 13y agoI'm glad you're finding Angular is working well for you! You may be (okay, considering what this article is about, you probably are) aware of this, but we're making an effort to drastically improve the performance of the dirty-checking algorithm. Miško wrote a draft paper (you know this, I know) regarding the dirty-checking implementation, and there's an implementation of it in Angular.dart. I've been working on porting the Angular.dart implementation over to ES6 for the next iteration of AngularJS over the past couple of days, and it's actually pretty challenging, so I'm reaching out to people who are interested for help: The repository is at http://github.com/caitp/watchtower.js http://github.com/caitp/watchtower.js, and will probably be moved into the angular org once it's a bit more fleshed out. Some things I'm looking for is assistance in improving the tests, and implementing a high quality performance test, possibly using our benchpress library (http://github.com/angular/benchpress http://github.com/angular/benchpress). I also would greatly appreciate hearing from people who are a bit more involved/experienced with ES6 might be able to offer some suggestions on how to organize the code, because Dart does not translate 1:1 into ES6, so some help there would be a big deal. Anyone who is interested in contributing in some fashion, please, you're more than welcome to. We want AngularJS 2.0 to be super-fast, and the more help with this, the better.