Slide 1

Slide 1 text

AngularArchitects.io | @ManfredSteyer Effective Signals in Angular 19+ Rules and Helpers

Slide 2

Slide 2 text

Application Code as a Script

Slide 3

Slide 3 text

Reactive Programming: Paradigm Shift!

Slide 4

Slide 4 text

Marble Run

Slide 5

Slide 5 text

Marble Run Data Binding

Slide 6

Slide 6 text

Agenda • Computed Signals • Resource API • Linked Signals • Effects & Reactive Helpers Rules of Thumb

Slide 7

Slide 7 text

About me… Manfred Steyer, ANGULARarchitects.io (Remote) Angular Workshops and Consulting Google Developer Expert for Angular Blog, Books, Articles, and Talks about Angular Manfred Steyer

Slide 8

Slide 8 text

Computed Signals

Slide 9

Slide 9 text

Demo Branch: 02a-input-signals

Slide 10

Slide 10 text

Reactive Flow with Computed desserts = signal([]); ratings = signal({}); ratedDesserts = computed(() => this.toRated(this.desserts(), this.ratings()));

Slide 11

Slide 11 text

Reactive Flow with Computed desserts = signal([]); ratings = signal({}); ratedDesserts = computed(() => this.toRated(this.desserts(), this.ratings()));

Slide 12

Slide 12 text

Reactive Flow with Computed desserts = signal([]); ratings = signal({}); ratedDesserts = computed(() => this.toRated(this.desserts(), this.ratings())); originalName = signal(''); englishName = signal(''); Load Desserts

Slide 13

Slide 13 text

Resource API

Slide 14

Slide 14 text

Resource API dessertsResource = resource({ request: this.dessertsCriteria, loader: (param) => { return this.#dessertService.findPromise(param.request); } }); Experimental in Angular 19

Slide 15

Slide 15 text

Resource API dessertsResource = resource({ request: this.dessertsCriteria, loader: (param) => { return this.#dessertService.findPromise(param.request); } }); dessertsCriteria = computed(() => ({ originalName: this.originalName(), englishName: this.englishName(), })); desserts = this.dessertsResource.value; ratedDesserts = computed(() => this.toRated(this.desserts, …));

Slide 16

Slide 16 text

Resource Prevents Race Conditions Pancakes Sacher Cake Ice Cream Pancakes

Slide 17

Slide 17 text

Resource Prevents Race Conditions Pancakes Sacher Cake Ice Cream Pancakes „switchMap semantics“

Slide 18

Slide 18 text

Demo Branch: 02c-resource

Slide 19

Slide 19 text

Architecture Rule #1 Derive state where possible Sync: computed Async: resource

Slide 20

Slide 20 text

Linked Signals

Slide 21

Slide 21 text

Read-only Signals and Data Binding store = inject(DessertDetailStore); originalName = this.store.originalName;

Slide 22

Slide 22 text

Read-only Signals and Data Binding store = inject(DessertDetailStore); originalName = linkedSignal(() => this.store.originalName());

Slide 23

Slide 23 text

Effects & Reactive Helpers

Slide 24

Slide 24 text

Connecting Reactive and Imperative World

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

Ideal-typical Tasks • Drawing on a canvas • Manual DOM manipulations • Logging • Synching with LocalStore Stuff, you cannot do with data binding Rendering (and similar tasks …)

Slide 27

Slide 27 text

Demo Branch: 04c-effects

Slide 28

Slide 28 text

Conclusion Architecture Rule #2 Avoid effects triggering business logic

Slide 29

Slide 29 text

Instead: Reactive Helpers like Resource API @ngrx/signals ngxtension Your Own …

Slide 30

Slide 30 text

Demo Branch: 08b-details

Slide 31

Slide 31 text

Reactive Helpers: Effects Under the Hood

Slide 32

Slide 32 text

Free eBook (6th Edition) angularArchitects.io/ebook

Slide 33

Slide 33 text

More: Angular Architecture Workshop • Maintainable Architectures with Modern Angular • Strategic Design with Nx & Sheriff • Micro Frontends with Federation • Signals and Your Architecture: CD & Zone-less, NGRX & Signal Store, RxJS-Interop English Version: Feb 2025 // Early Bird until Dec 22, 2024 https://www.angulararchitects.io/workshop-en

Slide 34

Slide 34 text

Conclusion Architecture Rule #1 Derive state where possible Architecture Rule #2 Avoid effects triggering business logic

Slide 35

Slide 35 text

Conclusion Reactive Helpers & Primitives • Resource API • Linked Signal • rxMethod & Co. in Signal Store • ngxtensions • …

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

Marble Run

Slide 38

Slide 38 text

ManfredSteyer AngularArchitects.io Slides & Examples Remote Company Workshops and Consulting http://angulararchitects.io