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

Effective Signals in Angular 19+: Rules and Hel...

Effective Signals in Angular 19+: Rules and Helpers @ngbe2024

Manfred Steyer

December 06, 2024
Tweet

More Decks by Manfred Steyer

Other Decks in Programming

Transcript

  1. Agenda • Computed Signals • Resource API • Linked Signals

    • Effects & Reactive Helpers Rules of Thumb
  2. 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
  3. Reactive Flow with Computed desserts = signal<Dessert[]>([]); ratings = signal<DessertIdToRatingMap>({});

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

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

    ratedDesserts = computed(() => this.toRated(this.desserts(), this.ratings())); originalName = signal(''); englishName = signal(''); Load Desserts
  6. Resource API dessertsResource = resource({ request: this.dessertsCriteria, loader: (param) =>

    { return this.#dessertService.findPromise(param.request); } }); Experimental in Angular 19
  7. 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, …));
  8. Read-only Signals and Data Binding store = inject(DessertDetailStore); originalName =

    this.store.originalName; <input [(ngModel)]="dessert.originalName" />
  9. Read-only Signals and Data Binding store = inject(DessertDetailStore); originalName =

    linkedSignal(() => this.store.originalName()); <input [(ngModel)]="dessert.originalName" />
  10. 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 …)
  11. 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
  12. Conclusion Reactive Helpers & Primitives • Resource API • Linked

    Signal • rxMethod & Co. in Signal Store • ngxtensions • …