When to use take() vs takeUntilDestroyed()?

Поділитися
Вставка
  • Опубліковано 21 січ 2025

КОМЕНТАРІ • 45

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

    Excellent content, Ms. Kurata. For the first time, I found clear explanations about how these operators work. Greetings from Brazil

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

      Glad it was helpful! Thanks for watching!

  • @albertkao5964
    @albertkao5964 4 місяці тому +1

    Stackblitz is extremely valuable!
    Cracking open the Angular and RxJS source code are very instructive!
    Links are useful!
    The summary at the end are excellent!
    Thanks!!!!

    • @deborah_kurata
      @deborah_kurata  4 місяці тому

      Great to hear! Thank you so much! 😊

  • @richarddefortune1329
    @richarddefortune1329 4 місяці тому +1

    Great video, as usually!
    Looking forward for the ngrx signal store course.

  • @joeyvico
    @joeyvico 4 місяці тому

    Yet another great tutorial. Many thanks Deborah! I would love to have a deep dive tutorial on error handling with the catchError and throwError operators, best practices and such. Thanks again

    • @deborah_kurata
      @deborah_kurata  3 місяці тому

      Thank you so much!
      Have you seen this one: ua-cam.com/video/L9kFTps_7Tk/v-deo.html

  • @anthonyfreneat6555
    @anthonyfreneat6555 4 місяці тому

    The clarity of the explanations was clearly at Chad's level

  • @chagamajaykumarreddy1897
    @chagamajaykumarreddy1897 4 місяці тому +1

    I am eagerly waiting for your videos always

  • @ErickRodrCodes
    @ErickRodrCodes 4 місяці тому +1

    This is something I need to show to my team of engineers. take(1) is basically useless. it is always suggested to destroy the HTTP Observable to avoid memory leaks with TakeUntilDestroyed

  • @AniketDeshbhratar
    @AniketDeshbhratar 3 місяці тому

    Beautifully explained

  • @DanIL_diaries
    @DanIL_diaries 4 місяці тому

    Thanks!

  • @user-shwan
    @user-shwan 4 місяці тому

    Thank you so much Deborah for another great thoughtful video!

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

    Would it make sense and align with RxJS best practices to trigger the necessary logic after a PUT/POST/DELETE request in the complete callback? This approach allows us to respond to changes while ensuring that we only update the state of services that still exist, avoiding logic execution for components or services that may have been destroyed.
    We achieve this by using `takeUntilDestroyed` and splitting the logic into two parts: one for the pipeline and next callbacks execution, and the other for side actions in the complete callback, such as updating state in another service provided at the root level.

  • @OlehBiblyi
    @OlehBiblyi 4 місяці тому

    I've got exactly same question about take(1), and here is another great video.

  • @CeezGeez
    @CeezGeez 4 місяці тому

    ty! your videos are invaluable!

  • @EmilioDegiovanni
    @EmilioDegiovanni 4 місяці тому +1

    What about using both in case of emits are less than the take(X)? ie: pipe(take(10), takeUntilDestroyed()). Then only happened 5 emits and component is destroyed.

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

      Yes! 😊 That would be good practice for long running Observables, such as a timer.

  • @fullsquatdev
    @fullsquatdev 3 місяці тому

    Great video, keep going

  • @GaryChike
    @GaryChike 4 місяці тому

    Great info!

  • @mohammadrezamrg9380
    @mohammadrezamrg9380 4 місяці тому

    What about Take(1) in http request with options in header? when we have preflight request.

    • @deborah_kurata
      @deborah_kurata  4 місяці тому +1

      AFAIK, HTTPClient still only emits one time with the response. So they take(1) still won't do anything.

  • @1frecin
    @1frecin 3 місяці тому

    Can I expect some tutorials on creating micro frontends in angular?

    • @deborah_kurata
      @deborah_kurata  3 місяці тому

      Probably not ... but this may help: nx.dev/concepts/module-federation/micro-frontend-architecture

  • @marshallgraphic
    @marshallgraphic 4 місяці тому +1

    Do you mean destroying an observable when using the HttpClient POST, PUT, or DELETE operations is unnecessary?

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

      If you look at the reasons it is so important to unsubscribe from an Observable:
      - Prevent memory leaks
      -> HTTP requests are one and done so won't leak memory (unlike timers or Subjects)
      - Cancel the request if navigating away
      -> Users most likely don't want their save requests cancelled. If they clicked a Save button and left a feature, they still want the save operation to complete.
      So, yes!

    • @marshallgraphic
      @marshallgraphic 4 місяці тому +1

      @@deborah_kurata Thank you for that :)

  • @rs4267
    @rs4267 4 місяці тому

    😊 thanks for this video

  • @chellaack1644
    @chellaack1644 4 місяці тому

    Thank awesome

    • @deborah_kurata
      @deborah_kurata  4 місяці тому

      Thank you!

    • @chellaack1644
      @chellaack1644 4 місяці тому

      @@deborah_kurata can you please post a video of memoized selector of ngrx ,I expecting and awaiting for long time

    • @deborah_kurata
      @deborah_kurata  4 місяці тому

      Great topic!
      I haven't worked with NgRx for a while, so my NgRx skills/knowledge is old and rusted. I have been considering getting back into it and covering some content, especially around signalStore. But looking at my current workload, I doubt I'd have time to look into it until late this year or early next year. So please don't wait for me on that topic.
      In the mean time, does anything here help? ngrx.io/guide/store/selectors
      Is there a non-NgRx topic you'd like to see?

    • @chellaack1644
      @chellaack1644 4 місяці тому +1

      @@deborah_kurata Thanks

  • @IvanIsmailov-hv9cg
    @IvanIsmailov-hv9cg 3 місяці тому

    Hey Deborah Kurata!
    You doing amazing job!
    You don’t have any courses in Udemy? I believe if you do courses there, you can find a lot of students who are willing to pay for your courses. 😊

    • @deborah_kurata
      @deborah_kurata  3 місяці тому

      Thank you!
      I tried to get set up with Udemy, but I was never able to get it to verify my identity. I tried to find somewhere to contact a person, but had no luck, so gave up on it.