process.nextTick

0 views
Skip to first unread message

manlycode

unread,
Nov 16, 2010, 1:39:25 PM11/16/10
to Grand Rapids NodeJS User Group
process.nextTick is neat. I saw this in the VowsJS documentation and
didn't really know what it was doing... so I cobbled up an example.

<script src="https://gist.github.com/702240.js"> </script>

manlycode

unread,
Nov 16, 2010, 1:41:16 PM11/16/10
to Grand Rapids NodeJS User Group
I really botched that one:

https://gist.github.com/702240

var sys = require('sys');

function printNowAndLater(message) {
sys.puts(message);
process.nextTick(function() {
sys.puts("Backgrounded Message: " + message);
});
};


printNowAndLater("Hello");
printNowAndLater("World");

cfurrow

unread,
Nov 16, 2010, 1:47:52 PM11/16/10
to Grand Rapids NodeJS User Group
Interesting. So it's basically a counter to setTimeout()? Seems like
process.nextTick() will run code on the next available cycle in the
event loop. Very cool, thanks for the link.

http://groups.google.com/group/nodejs/msg/3cf298bef510b4b1
Reply all
Reply to author
Forward
0 new messages