Angular & RxJS Tips #5: Multiple Http calls - combineLatest vs forkJoin

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ส.ค. 2024
  • In RxJS you can make multiple REST calls, wait that all of them are completed and get a single result.
    You can use forkJoin and combineLatest RxJS operators to achieve this result.
    So, what’s the difference?
    Level: intermediate
    ----
    Follow me on:
    • LinkedIn: / fabiobiondi
    • Twitch: / fabio_biondi

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

  • @g3co875
    @g3co875 2 ปีที่แล้ว +1

    these short videos are programming gems, please, keep doing them! thanks for your time!

  • @meraku9390
    @meraku9390 ปีที่แล้ว

    this is a very precise and concise video, without using those default examples, excellent !!

  • @LeonardoBuscemi
    @LeonardoBuscemi 2 ปีที่แล้ว

    I love this video! Thank you so much

  • @ahmadbenchakhtir5787
    @ahmadbenchakhtir5787 ปีที่แล้ว

    broooooooooooooo, This Explain are amaziiiiiiing.

    • @FabioBiondi
      @FabioBiondi  ปีที่แล้ว +1

      thank you for the feedback Ahmad

  • @MelodiousMusic2458
    @MelodiousMusic2458 ปีที่แล้ว

    Hey, it is little bit difficult to understand the accent but quality of content is very good. By the way what is your native language?

    • @FabioBiondi
      @FabioBiondi  ปีที่แล้ว +1

      thank you. I'm trying to improve my english but it will be a looong journey 🤣

  • @MikeDePetris
    @MikeDePetris 2 ปีที่แล้ว

    complex things

  • @MikeDePetris
    @MikeDePetris 2 ปีที่แล้ว

    Can you help me on a different situation please, that is not really nested calls but instead a sequence of call where the results have to be concatenated. I call service.getItems(p1).suscribe(res=>{this.allItems = res; service.getItems(p2).subscribe(res =>{this.allItems = this.allItems.concat(res); ... many nested calls, you get?

    • @FabioBiondi
      @FabioBiondi  2 ปีที่แล้ว +2

      If you need to concat previous result with the new one you should do something similar (hard to write here in a YT comment).
      If you prepare a stackblitz with a real world case I can help you more.
      service.getItems(p1)
      .pipe(
      mergeMap(res => service.getItems2(res).pipe(map(res2 => [...res2, ...res2]) )
      .. so the next operator will receive the merge of previous results and you can do another mergeMap doing the same...
      )
      .subscribe(res => {
      // res is now the merge of previous results
      })

    • @MikeDePetris
      @MikeDePetris 2 ปีที่แล้ว

      ​@@FabioBiondi so many thanks for the quick answer, will have a try and prepare a stackblitz for sure, as I am procratinating this issue for too long

    • @MikeDePetris
      @MikeDePetris 2 ปีที่แล้ว

      @@FabioBiondi I made you editor of a stackblitz Data API Rest Angular (forked)

    • @FabioBiondi
      @FabioBiondi  2 ปีที่แล้ว

      @@MikeDePetris where can I find it?

    • @letri8757
      @letri8757 2 ปีที่แล้ว

      @@FabioBiondi When i use mergeMap, i always make sure the inner observable is a completed observable. If not, will have a memory leak ! Is it a right things ?