4 ms·
To chime in with another viewpoint: I've just written a sort of remote-control solution that can use WebSockets and fall back to SSE (Server-Sent Events) + HTTP
by aktau 13y ago
To chime in with another viewpoint: I've just written a sort of remote-control solution that can use WebSockets and fall back to SSE (Server-Sent Events) + HTTP POST if necessary. I wrote it in node.js, which I hadn't used before, because it had (has) great libraries for both WebSockets and Server-Sent Events. So I though I would put to use the adagio "best tool for the job". I don't regret it because I was able to write this thing in about 5 days and together with runit restarting it when it throws an exception I have a solution that hasn't failed me yet.
But... I really kinda hated the callback spaghetti, and no matter what library I tried (Step, Async, ...), I couldn't get myself to feel more comfortable with it. So I decided I would only use node.js when the libraries make it too hard to pass up.
- CoryG89 13y ago>So I decided I would only use node.js when the libraries make it too hard to pass up. So, all the time then? --For me at least ;)
- etler 13y agoDo you use the module feature that much? If you break your code down into small enough pieces it's less of a problem. Also the terseness of coffeescript functions makes anonymous functions less painful.
- Oculus 13y agoI had a similar experience with the callback spaghetti at first. It felt kind of off and awkward. Once I got the hang of it (day or two), I started really enjoying all the callbacks and passing functions everywhere. Maybe all this Javascript coding finally got to me and now I'm crazy :)
- diminoten 13y agoI've found it becomes almost an art, trying to write your code without having to fall into the callback quagmire. You can usually do it, though. Usually.
- olegp 13y agoHave you looked at https://github.com/olegp/common-node https://github.com/olegp/common-node?
- embwbam 13y agoPromises are the only real solution. https://github.com/kriskowal/q https://github.com/kriskowal/q
- bilbo0s 13y agoIt's still callback spaghetti though right. You still need to break function "doAll()" into function "doPart1()", "doPart2()"...,"doPartN()". It's just that now you have a new syntax for calling all of the functions. Like Rx for JavaScript instead of C#. I do believe the syntax for calling all of the component functions is better.. but it would be great if you didn't have to make the component functions at all.