JavaScript Quick Tip Fetch in Parallel

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ต.ค. 2024
  • One gotcha that comes up frequently and has a serious impact on application performance is the tendency to accidentally fetch data in serial that could have been fetched in parallel. Don't just drop an await in everywhere you use promises. Instead, think about the fetching dependencies. If you're fetching more than one thing, make sure you fetch in parallel whenever you can. This will make a huge difference in your application's performance.
    Resources for remote software developers:
    DevAnywhere - Live, remote 1:1 mentorship subscription: DevAnywhere.io
    EricElliottJS.com - Learn TDD, functional programming, software design principles and JavaScript with online, interactive lessons. ericelliottjs.com
    Composing Software eBook: leanpub.com/co...
    Composing Software paperback: amzn.to/3biid58
    ---
    Eric Elliott is the author of the books, “Composing Software” and “Programming JavaScript Applications”. As co-founder of EricElliottJS.com and DevAnywhere.io, he teaches developers essential software development skills. He builds and advises development teams for crypto projects, and has contributed to software experiences for Adobe Systems, Zumba Fitness, The Wall Street Journal, ESPN, BBC, and top recording artists including Usher, Frank Ocean, Metallica, and many more.
    He enjoys a remote lifestyle with the most beautiful woman in the world.
    #JavaScript #Code #SoftwareEngineering

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

  • @felipezarco9502
    @felipezarco9502 4 ปีที่แล้ว +11

    Good and straightforward content. Love it!

  • @eyjaythejansenite3253
    @eyjaythejansenite3253 4 ปีที่แล้ว +5

    I was first introduced to your work by watching your video "Classical inheritance is obsolete........". I've been learning JS, and almost every tutorial or lesson I go to always introduces classes first.
    I keep going to your article and video all the time. Thank you for your work. Love these little tips.

  • @franco-cespi
    @franco-cespi 4 ปีที่แล้ว +2

    Thanks for the tip. I like how you went straight to the point.

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

    Thank you! Love your gpt-3 interview and hi from New Zealand!

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

    thank you elliot
    didnt know about this

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

    Straight forward and really helpful. Appreciate it!

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

    Great quick tip! Thanks!

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

    Damn, this is so obvious in hindsight. Feel silly for not doing this before.

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

    Man you´re my hero!! thanks!!

  • @Anonymous-vh6kp
    @Anonymous-vh6kp 4 ปีที่แล้ว

    Learn something new everyday! Thanks. I wonder why call in the first example don't run in parallel...

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

      Well, that's what the "await" keyword is all about. Each line will "await" until the async operation finishes before passing the ball to the next await operation.

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

    Thanks for the info 👍

  • @sujitkumarsingh3200
    @sujitkumarsingh3200 4 ปีที่แล้ว

    That's my fav. interview question but with slight twist(error cases). Which can be handled by allSettled, but I like custom implementation untill the function becomes common.

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

    Of course the real answer to the riddle is that one should request everything needed in one request.

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

      Not always possible, but great tip!

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

    That's the problem with async/await. It makes people think of promises as sync calls and use them in a blocking way.

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

      Yep. As with all super convenient tools, there is a time and a place.

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

    Thanks a lot!

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

    :-) when possible, start promises asap and await only when you *need* to use the data

  • @michaelkashkov4337
    @michaelkashkov4337 3 ปีที่แล้ว

    Helpful =)

  • @brandyscrow
    @brandyscrow 3 ปีที่แล้ว

    cool