Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Change Detection - Deep Dive

Change Detection - Deep Dive

Rainer Hahnekamp

February 29, 2024
Tweet

More Decks by Rainer Hahnekamp

Other Decks in Technology

Transcript

  1. RainerHahnekamp About Me... Professional NgRx https://www.youtube.com/ @RainerHahnekamp https://www.ng-news.com https://github.com/softarc-consulting/sheriff •

    Rainer Hahnekamp ANGULARarchitects.io • Developer / Trainer / Speaker Modern Spring for Angular @RainerHahnekamp
  2. RainerHahnekamp 1. Change Detection with Default Strategy = OnPush =

    Default 1. Waiting for Events 3. Dirty Marking 4. Change Detection zone.js 2. Event Happens
  3. RainerHahnekamp Change Detection: OnPush • Only checks if Component is

    dirty • No dirty marking by asynchronous task!
  4. RainerHahnekamp 2. Change Detection: Click Event in Default Component =

    OnPush = Default 1. Waiting for Events 3. Dirty Marking 4. Change Detection zone.js 2. Event Happens
  5. RainerHahnekamp 3. Change Detection: Click Event in OnPush Component =

    OnPush = Default 1. Waiting for Events 3. Dirty Marking 2. Event Happens 4. Change Detection zone.js
  6. RainerHahnekamp Criteria markForCheck Immutable Property Binding Handled DOM Events async

    Pipe Signal Change (Local Change Detection) manually via markForCheck
  7. RainerHahnekamp 4. Local Change Detection: Signal Change in OnPush Component

    = OnPush = Default 1. Waiting for Events 3. Dirty Marking 4. Change Detection zone.js 2. Event Happens
  8. RainerHahnekamp Change Detection in the Future • Careful with OnPush

    with zone.js • "Acceptable" with upcoming Scheduler • Simple & Easy with upcoming Signal Components