How to do readable.pause() in node.js so that readable.on('end', function(){}) is not emitted? -


I am consuming a bunch of data in my express node. Js app. Before taking more data, I have to wait to complete one of my operations.

  req.on ('data', function (data) {req.pause (); do_my_thing (); req .reume ();} req.on ('end', function ( } {do_my_finish_thing}}}   

The problem is that req.on ('end', () {}) is still called whenever I stop the stream. There is no way to prevent that ('end', () {}) is not emitted?

What you should do, but 'do_my_thing' function will be executed with asynchronous, therefore, it is almost instantaneous

You can resume stream in do_my_thing callback:

  function do_my_thing (callback) {// your work callback () ;} req.on ('data', function (data) {req.pause (); do_my_thing (function () {req.resume ();})}} req.on ('end', function () {do_my_finish_thing }}}    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -