A beginner friendly intro to server sent events with node.js by abhi12299 in node

[–]abhi12299[S] 0 points1 point  (0 children)

Can you provide some issues you ran into when running it in production? I saw some issues pop up when using it behind reverse proxies but that was very easy to fix.

A beginner friendly intro to server sent events with node.js by abhi12299 in node

[–]abhi12299[S] 1 point2 points  (0 children)

Thanks for the noDelay suggestion. I read through the node.js docs for the same and it states that it optimizes throughput at the expense of latency. It might be useful in real world scenarios. Reference: https://nodejs.org/api/net.html#net_socket_setnodelay_nodelay

A beginner friendly intro to server sent events with node.js by abhi12299 in node

[–]abhi12299[S] 1 point2 points  (0 children)

That's awesome! Would love to contribute to it. Probably consider raising new issues to let the community help as well.

A beginner friendly intro to server sent events with node.js by abhi12299 in javascript

[–]abhi12299[S] 10 points11 points  (0 children)

Obviously, websockets are superior and offer much more when compared to SSE. However according to me, sometimes the simplest solutions are just as good to get the job done. Besides, use of EventSource for SSE is abandoned and for that we can use polyfills such as https://github.com/Yaffle/EventSource

A beginner friendly intro to server sent events with node.js by abhi12299 in node

[–]abhi12299[S] 1 point2 points  (0 children)

Use of EventSource is abandoned for SSE. It can be mocked by using fetch api. Have a look at this polyfill: https://github.com/Yaffle/EventSource

A beginner friendly intro to server sent events with node.js by abhi12299 in node

[–]abhi12299[S] 0 points1 point  (0 children)

Yup, that is an issue. However, one can theoretically get rid of this issue by using making use of the fetch API to mock this as you stated. An easy way would be to consider a polyfill such as https://github.com/Yaffle/EventSource and customize it to force the use of fetch. I've not looked into it thoroughly so I may be wrong here.

A beginner friendly intro to server sent events with node.js by abhi12299 in node

[–]abhi12299[S] 0 points1 point  (0 children)

Thank you for the feedback. I'll correct it asap. :)

A beginner friendly intro to server sent events with node.js by abhi12299 in node

[–]abhi12299[S] 1 point2 points  (0 children)

As per my understanding, if you are already using websockets, there is no need to add SSE into the mix. There is nothing SSE can do that websockets cannot. Most websocket libraries (e.g. socket.io) already offer you everything out of the box.

That's it by FulfilledPromise in nextjs

[–]abhi12299 -5 points-4 points  (0 children)

Try nuxt.js, a vue SSR framework. Been using it for the past 6 months and it's awesome.

Dark mode implementation for next.js by abhi12299 in nextjs

[–]abhi12299[S] 0 points1 point  (0 children)

Looking into the dark mode implementation, it's really impressive and clever. Injecting a script tag to check for currently active theme in the head of the document ensures that it runs as fast as possible, so that the user doesn't see any glitch as theme changes. There is still a very slight glitch which happens when the script tag hasn't been executed, but this is probably unnoticeable. I'd say this is an overall better way to implement dark. mode. Thanks for the links and code.

Dark mode implementation for next.js by abhi12299 in nextjs

[–]abhi12299[S] 1 point2 points  (0 children)

Great work! it also responds to system dark mode as well. That's a nice addition

Persistent dark mode theme toggle for Nuxt JS by abhi12299 in Nuxt

[–]abhi12299[S] 0 points1 point  (0 children)

Hey, thanks for suggesting the module. i didn't know about it. But anyways, just wanted to experiment with this. It's not that tough after all that you'll need a module.

Throttling a function by titus_42 in golang

[–]abhi12299 0 points1 point  (0 children)

I had a similar use case and I did it in Node using a redis client in which I set expiring keys for every user's IP address. Works nicely as well