1. this has 2 parts.
first part, when you call an async function, the control is given back to
the event loop. somewhere, at the end of the current stack there is
registry, managed by the loop. in this registry is maintained which
function, or better function object, is associate with which ev
Hi people!
Aman, bad english here ;-)
But part of the answer: yes, for JavaScript (not for all the internal guts
of Nodejs) there is only one thread. One way the state is preserved is
using local variables in functions/callback and using the previous
arguments. See also JavaScript closures:
http
On Aug 8, 2013, at 1:03 AM, aman saggar wrote:
> 1)How is the state is being maintained here?
>
> a. If this is single threaded model, then the with the second request
> coming, it wouldn’t have idea of the initial request or state
>
>
Apologies for being ignorant here.
A simple Node.js non-blocking implementation (stupid but just to show the
point):
var http = require("http");
http.createServer(function (request, response) {
//Query 1st Database based on user Id
db1.query("select x,y from DB1 where userId=" +