Tisamu
12/18/2017 - 9:26 AM

Synchronous Operations

Make Synchronous Operations from Asynchronous functions one after each other.

# Requires async package
yarn add async
async.waterfall([
    function (callback) {
      // Here Do Something..
      // callback(null, {any}); is needed to proceed to the next function,
      // If we don't call callback(), the waterfall will never finish.
      callback(null, data);
    },
    function (callback, data){
      // Do Something from the data received from the previous function..
      callback(null, other_data);
    },
    function(callback, other_data){
      // Do Something from the other_data reveived from the previous function..
      callback(null);
    }
  ], function (err) {
    console.log('OK, Waterfall ended here');
    filter();
  });