2 ms·
I 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 relatio
by EvanPlaice 11y ago
I 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.