Monday 7 December 2015

I'm a PHP coder and I want to switch to node.js, but I'm finding async a bit of a task to wrap my head around. What can I do about this?

Contemplated making this post for a while and I figured I would do it now.I've wanted to switch to node.js for a long time, for the last 2-3 years at least I've had the thought and made a couple of attempts.However it seems that coming from PHP I'm having a hard time, mainly with wrapping my head around async and callbacks. Not sure how many people her tried PHP but just in case you have not: everything is synchronous. I think this in node.js is referred to as a "blocking" or something.I'm quite lost in how to structure things and mainly how to control the flow of tasks in the order I want. I found just doing a loop with an async task inside ended badly and required a bunch of callbacks and waiting methods and functions to encapsulate the async code to get the result I desired.From what I first read I was scared off, that if you do any synchronous code in a node.js app then it locks up the entire node process and it cant process anything until its finished. Is this true?Ok, tl;dr: I suck at async and callback structuring and task flow management, what can I do about it? :D

Submitted December 08, 2015 at 02:04AM by Linkandzelda

No comments:

Post a Comment