node.js - How to do asynchronous processing in nodejs -


I'm a newbie in node js and am trying to create a simple app for creating web pages from RSS feeds.

  http.get ('http://www.someurl.com/news?output=rss', function (ridge) {res.on ('data', function (piece) { ResLength + = Chunk.length; chunks.push (chuck);}); res.on ('end', function (chuck) {// all chunks and process feed XML.})}}  

Server response processing can go longer and can block the main thread.

How can I create an async operation to process an intermediate server response and return the result Can I send?

In nodes, you should not do any such stuff that uses a wider CPU time because it is a single threaded server (event loop). Do not block. Server keeps requesting and other things, when the request comes back (after millions of clock cycles), you can execute the callback, you are the only indicator for the callback.

Now, you have asynchronous Also requests can not be processed in a wide range of CPU usage, all other requests work like that Asnsuon.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -