Long Polling in NodeJS

Sdílet
Vložit
  • čas přidán 20. 07. 2020
  • 📘New Course: Build full-stack React Typescript applications tsreact.maksimivanov.com/s/ytd
    Long polling in nodejs using the request / response stream objects.
    Code: github.com/satansdeer/req-res...
    Where to find me:
    Twitter: / satansdeer
    Discord: / discord

Komentáře • 19

  • @RockieYang
    @RockieYang Před rokem +1

    Great explanation, simple and clear

  • @saptarshidey13
    @saptarshidey13 Před 3 lety +15

    Why not use setInterval instead of calling setTimeout recursively?

    • @mdhuzaifa
      @mdhuzaifa Před 2 lety +7

      setInterval will send a request every set period of time irrespective of the previous request's response. This will create a backlog of requests and an unnecessary amount of complexity in handling the data.

    • @shivomsrivastava6540
      @shivomsrivastava6540 Před 2 lety +3

      @@mdhuzaifa Nice question and a good answer ❤

    • @TheHarsh2318
      @TheHarsh2318 Před rokem +2

      Using setInterval we basically implement short polling

    • @craftoverflow
      @craftoverflow Před rokem

      @@mdhuzaifa Irrespective of the previous request's response? Not even if you clearInterval before setting the next one?

  • @tech.craftsman
    @tech.craftsman Před 2 lety

    Subscribed

  • @priyanshubaluni2801
    @priyanshubaluni2801 Před 4 lety +4

    Please make some videos on MERN stack... Love your teaching❤️

  • @grubstarstar
    @grubstarstar Před 3 lety +1

    How do you get the autocomplete on the command line? I need that 🙂

    • @FlorianEagox
      @FlorianEagox Před 3 lety

      It's an awesome tool called ZSH. It replaces your regular bash shell

    • @corey4448
      @corey4448 Před 2 lety

      @@FlorianEagox I hope you mean ZSH + OMZ. If want battery-packed, try Fish.

  • @ashishmaurya3113
    @ashishmaurya3113 Před rokem

    why setTimeout was calling recursively…¿

  • @tech3425
    @tech3425 Před rokem

    Basically don't use methods that implicitly or explicitly end the response object.

  • @chellathurais650
    @chellathurais650 Před 3 lety +1

    How he able to assign connections=[ ] even after declaring it as const.

    • @kalekber
      @kalekber Před 3 lety +3

      If it was a typescript or any linter enabled it would have thrown an error immediately but since JavaScript is an interpreted language it will only throw the error when it runs and goes to that line. The video did not last long to see it though.

    • @chellathurais650
      @chellathurais650 Před 3 lety

      @@kalekber so It means that the code never reached that condition till the runtime of this video right?

    • @kalekber
      @kalekber Před 3 lety +1

      @@chellathurais650 right, if you pay attention to the if statement, when the tick variable will go over 20 it will hit the logic inside and throw the error

  • @artemaveryanov6546
    @artemaveryanov6546 Před 4 lety +1

    Why are you do all content on English? How many people from (Russia/Ukraine and etc) keep watching you? Have you thought to keep making your content, but on your native language?

    • @divyanshujuneja1291
      @divyanshujuneja1291 Před 2 lety +6

      Why not make this comment in your native language too? CZcams is platform for world, not just Russia and Ukraine. Let's not forget that CZcams is a company from a country whose native language is English.