Angular Signals & the new resource & rxResource methods for Efficient Data Fetching (First look)

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ธ.ค. 2024

ความคิดเห็น • 13

  • @arpitgarg6459
    @arpitgarg6459 หลายเดือนก่อน

    As an extensive rxjs user, I find the rxResource method much more easier and intutive to use in my daily routine. Thanks for the great explanation. Love your videos...

  • @heliyarb9604
    @heliyarb9604 17 วันที่ผ่านมา +1

    very very useful.thank you😀

    • @CodeWithAhsan
      @CodeWithAhsan  17 วันที่ผ่านมา

      @@heliyarb9604 awesome! Glad it helped :)

  • @tjlav5
    @tjlav5 หลายเดือนก่อน +4

    Value is T|undefined because the value is undefined until the loader resolves (or when a new request kicks off)

    • @CodeWithAhsan
      @CodeWithAhsan  หลายเดือนก่อน

      Makes sense. Thanks for sharing!

  • @alissonprimo
    @alissonprimo หลายเดือนก่อน +1

    Great explanation! Thanks! ❤

  • @alm-r4w
    @alm-r4w หลายเดือนก่อน +1

    unrelated the to the video but i would really like to hear your input on this:
    i work with angular for few years now and i mostly saw people design http request function in a way that it always returns the data directly in the component its used in. and i do so to bc i never thought of doing this differently. so only recently i discovered the idea of saving http requests in variable inside the service and then work with behaviour subjects to update components with the data from the that variable and work with behaviour subjects. And in every case where u use data data multiple times it seems way more logical and practical for statemanagement so i started using it this way almost everywhere except if i only need to get the data once in a single component.
    but since i rarely see it i wonder if there is a flaw in my thinking.
    What do u think is the best practice when it comes to this.

    • @CodeWithAhsan
      @CodeWithAhsan  หลายเดือนก่อน +1

      @@alm-r4w great question. I think your approach is okay as well. however it requires a bit of care to not mess up.
      In the case of having the data in the service , you are still keeping the data in the service even if you’re not using it anymore. Or the purpose of the data has been fulfilled by being rendered on view.
      It will also make the testing a bit harder since your data is bound to your service . You won’t be able to mock it easily.
      The best practice I think it will be to receive the data from the API and to let it go, or save it into your state as required. In my opinion, request data, component state, and/or service variables shouldn’t be tightly coupled.
      The more isolation you have , the easier it is to perform unit tests.

    • @alm-r4w
      @alm-r4w หลายเดือนก่อน +1

      @@CodeWithAhsan Ok i think i understand, so if in need of reusing the data cross multiple components u would work with two sepperate services one for the api fetching and one for state management?

    • @CodeWithAhsan
      @CodeWithAhsan  หลายเดือนก่อน

      @@alm-r4w Exactly!

  • @finnb6390
    @finnb6390 16 วันที่ผ่านมา

    Maybe i missed it, while watching the vid, but the resource API automatically unsubscribes our service calls inside the loader function?

  • @nebojsazakic
    @nebojsazakic หลายเดือนก่อน +3

    Until the signal resolves the value is undefined. Please use ?? instead of ||.

    • @CodeWithAhsan
      @CodeWithAhsan  หลายเดือนก่อน

      Makes sense! Thanks 👍🏼