3 ms·
Well, that's sort of the difference between composing libraries to build applications and using a framework like Angular. Angular abstracts away a lot of thing
by chrisco255 11y ago
Well, that's sort of the difference between composing libraries to build applications and using a framework like Angular. Angular abstracts away a lot of things. This is good and bad. It's easier to get into Angular and get started sooner. But ask an Angular dev to explain the digest cycle to you, or transclusion or when and why to do one-way or two-way binding, and the relative merits of calling $parent or using controllerAs syntax. It's a really confusing mess. And folks use it without understanding how it works.
With react, I can explain, quite simply, that it's simply a function: (state, props) => HTML . That is elegant as fuck. There no dirty checking, no two way binding or unintended side effects by cross-referenced observables.
React-Router is only necessary if you want to build a SPA. Then you learn how it works, or you use some other router (like Redux-Router). It's great. You actually understand how your code works.
It's a steeper learning curve up front, but you learn and you become a better developer as a result.
- EvanPlaice 11y agoI could explain how Angular2 works in great detail. It mimics the hell out of OOP. The component tree is a directed acyclic graph of single-inheritance relationships. Services are singletons that can be injected into any component to share state. Dirty checking follows the tree (ie the DAG) of inputs/outputs specified in the component metadata so there's at most O(log n) comparisons per update. To make dirty checking efficient favor immutability because it's quicker to superficially compare references than it is to deep check an entire data structure. Anything that's inherently asynchronous is handled via Rxjs observables using either a one-to-one or one-to-many publisher/subscriber model. As for Angularjs. Who the hell knows? Dirty checking, crawls the graph of relationships until the dirty checker gets tired. Services are kind of like singletons, I think. Factories try to mimic the borg/prototype pattern (because, reasons...) to provide singletons that share a reference to a common closure. Who the hell knows what providers do, maybe provide an instance that acts like a static helper class? Directives are magic, really complicated and painful to use magic that preprocess the HTML, who the hell knows when.