The problem with Angular Signals and Async Reactivity

Поділитися
Вставка
  • Опубліковано 9 лип 2024
  • #angular #signals #rxjs
    💖 The complete app I was building can be found on my shop
    buymeacoffee.com/zoaibkhan/e/...
    📽️ My courses:
    zoaibkhan.com/courses
    ✍️My blog for more free Angular posts:
    zoaibkhan.com/blog
    In this video, I discuss a problem I got with implementing a very common front-end problem using the Signals API in Angular. And the best way to resolve it!
    Socials:
    Twitter - / zoaibdev
    Facebook - / thisiszoaib
    LinkedIn - / zoaib-khan-b6456815
    00:00 Introduction to Angular's Signals API Challenge
    00:25 Exploring the Initial Approach with ngOnInit
    02:10 Addressing Reactivity with Effects Primitive
    04:25 Switching to RxJS for Enhanced Reactivity
    06:36 Optimizing with Observable to Signal Conversion
    08:54 Introducing Derived Async for Simplified Implementation
    10:43 Conclusion and Final Thoughts
    Cheers!
  • Наука та технологія

КОМЕНТАРІ • 18

  • @flywheel56
    @flywheel56 2 місяці тому +1

    Pertinent, useful, and very up to date info on the new way of working with Angular. Thanks.

    • @ZoaibKhan
      @ZoaibKhan  2 місяці тому

      You're welcome 🤗

  • @MichaelSmallDev
    @MichaelSmallDev 2 місяці тому

    I'm pretty sure some feature I wrote today would have been easier if I saw this first. I may just refactor it to be more like this video. Good stuff.

    • @ZoaibKhan
      @ZoaibKhan  2 місяці тому

      Glad to hear you found it useful! There's also the ngrx signals package and it's rxMethod function - that does the same thing in an RxJS way...

  • @elsecoding8691
    @elsecoding8691 Місяць тому

    This is good stuff. Thanks for sharing 👍👍

  • @PatricioHondagneuRoig
    @PatricioHondagneuRoig 2 місяці тому

    Cool video, very informative take. Thanks for sharing!

    • @ZoaibKhan
      @ZoaibKhan  2 місяці тому

      Glad you found it useful! :)

  • @WeAreMuslim320
    @WeAreMuslim320 2 місяці тому

    Please also upload videos in urdu for better understanding thanks a lot.

  • @KostasOreopoulos
    @KostasOreopoulos Місяць тому

    Or we can wrap the signal sets in an untracked scope I guess. But looking at the source code of derivedAsync, its very very clever.

    • @ZoaibKhan
      @ZoaibKhan  Місяць тому

      Oh, I haven't looked at it in detail myself. Can you share some of the clever stuff there? :)

    • @KostasOreopoulos
      @KostasOreopoulos Місяць тому

      @@ZoaibKhan It converts the promise if given to an observable, flattens it, uses DestroyRef, which I have never heard of to unsubscribe on destroy, peaks on the initial value in an untracked scope to avoid recursion, does the computation in an untracked scope, and gives back a computed signal based on the objeservable's next value. Its a little bit confusing because it tries to handle a lot of function signatures in the same function

    • @ZoaibKhan
      @ZoaibKhan  Місяць тому +1

      @@KostasOreopoulos Wow, that's quite a lot! Respect for the maintainers increased even more :)

  • @arpitgarg6459
    @arpitgarg6459 2 місяці тому

    why can't we used computed in place of derviedAsync?

    • @ZoaibKhan
      @ZoaibKhan  2 місяці тому +4

      Because computeds are meant for sync reactivity, they can't have delays or promises or anything async in them.