Long Polling in NodeJS
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
Great explanation, simple and clear
Why not use setInterval instead of calling setTimeout recursively?
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.
@@mdhuzaifa Nice question and a good answer ❤
Using setInterval we basically implement short polling
@@mdhuzaifa Irrespective of the previous request's response? Not even if you clearInterval before setting the next one?
Subscribed
Please make some videos on MERN stack... Love your teaching❤️
How do you get the autocomplete on the command line? I need that 🙂
It's an awesome tool called ZSH. It replaces your regular bash shell
@@FlorianEagox I hope you mean ZSH + OMZ. If want battery-packed, try Fish.
why setTimeout was calling recursively…¿
Basically don't use methods that implicitly or explicitly end the response object.
How he able to assign connections=[ ] even after declaring it as const.
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.
@@kalekber so It means that the code never reached that condition till the runtime of this video right?
@@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
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?
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.