Use decorator to beat ngOnChanges – Decoupling ngOnChanges
summary
Claim: replace bulky ngOnChanges with a TypeScript property decorator that uses Object.defineProperty under the hood to add per-property getters/setters, compare old and new values, and call a typed callback with a SimpleChange generic. Implementation uses symbol-backed instance keys, optional equality check, and generics for correct types. Author ships it as an npm package, it works for @Input and regular or dynamic properties, and it eliminates the single ngOnChanges block while preserving previous/current values.
AI-written summary · about
chapters (5)
related talks
32mDemystifying TypeScript Decorators
18mReactive Patterns For Angular
16mDiscover the power of decorators in TypeScript
48mFalling in love with decorators ES6/TypeScript
46mTypeScript Decorators - Higher Order Functions in Disguise
34mHigh-Performance Applications with Angular
01h 02mChange Detection, Zone.js and Other Monsters
33mAngular 2 change detection explained
