Slide 1

Slide 1 text

Our Journey to Fine-Grained Reactivity in Angular By Maina Wycliffe

Slide 2

Slide 2 text

Maina Wycliffe Software Engineer Author All Things Typescript www.allthingstypescript.com Twitter: @mwycliffe_dev LinkedIn: mainawycliffe

Slide 3

Slide 3 text

Reactivity in Web Frameworks? - Syncing State with View - View = Function(state) - Detecting changes when they happen - User Actions - Button Clicks - Form Entries, etc - Browser API Changes - Browser Resizes - Scroll Events, etc.

Slide 4

Slide 4 text

Change Detection Models Pull-based Change Detection - The Frameworks Checks For Changes - E.g. Angular Push-based Change Detection - Components alert the framework of changes - Renders immediately after change happens - E.g. React

Slide 5

Slide 5 text

Change Detection in Angular - Push-based change detection - No setState or similar in Angular - Performance impacts on larger applications

Slide 6

Slide 6 text

Fine-grained Reactivity - What is? - Targeted change detection - Only affected components/view are updated - Tracking of Dependencies

Slide 7

Slide 7 text

Signals - what are they? - Notifies interested parties when something has changed - Directly mutation APIs - signal.update(newValue) - Automatic tracking of Dependencies - signal() getter adds dependencies - Fine-grained reactivity - Effects - Listeners for when something changes

Slide 8

Slide 8 text

Signals For Angular - Signal based components - Local/component based change detection - Per view change-detection - Fine-grained reactivity - @Inputs, ViewChild Queries, Models will be signals - CD will only run when inputs are read - Optional Zone.js

Slide 9

Slide 9 text

Why not RxJS? - Observables are Asynchronous by nature - No initial values - You need an async pipe to read values - Observables have side effects - HTTP Calls etc - Not pure functions - RxJS and Signals will work together - RxJS for Async Operations - Signals State Management and CD - Interoperability of Signals with RxJS - Provide initial values when subscribing to RxJS - May be - the end of Async Pipe in the future

Slide 10

Slide 10 text

Impacts of Signals in Angular - Improved Performance in Large Applications - Possible future benefits: - SSR and Hydrations - - Modern Hydration Techniques: - Resumability, - Progressive Enhancements, - Automatic Islands, etc. - Improvement Developer Experience - Hot Module Reloading Improvements in Angular - Mental Model Switch with Signals - Changes to Life Cycle Hooks - Effects - RxJS and Signals Interoperability - Functions in Templates, etc.

Slide 11

Slide 11 text

Resources - Signals RFC - RFC: Angular Signals🚦 · angular/angular · Discussion #49685 (github.com) - Sub-RFC 1: Signals for Angular Reactivity · angular/angular · Discussion #49684 (github.com) - Sub-RFC 2: Signal APIs (github.com) - Sub-RFC 3: Signal-based Components (github.com) - Sub-RFC 4: Observable and Signal Interoperability (github.com) - useSignal() is the Future of Web Frameworks (builder.io)

Slide 12

Slide 12 text

Thank You