simple-flow-control

1.0.1 • Public • Published

Usage

Install

$ npm install simple-flow-control

Creating an instance

var Serial = require('simple-flow-control').serial;
var serial = new Serial();
// or
var serial = Serial();

Register task

var f1 = function() {};
serial.registerTask(f1);

Executing tasks

serial.start('Initial value');

Example

var Serial = require('simple-flow-control').serial;

var serial = new Serial();
// or
var serial = Serial();

var f1 = function(result, next) {
  setTimeout(function() {
    console.log('Function 1 executed!', result);
    next(null, 'Value send by function 1');
  }, 2000);
};

var f2 = function(result, next) {
  setTimeout(function() {
    console.log('Function 2 executed!', result);
    // next(new Error('Bugou tudo'), 'Value send by function 2');
    next(null, 'Value send by function 2');
  }, 3000);
};

var f3 = function(result, next) {
  setTimeout(function() {
    console.log('Function 3 executed!', result);
    next(null, 'Value send by function 3');
  }, 3000);
};

serial.registerTask(f1);
serial.registerTask(f2);
serial.registerTask(f3);

serial.start('Initial value');

Dependencies (0)

    Dev Dependencies (4)

    Package Sidebar

    Install

    npm i simple-flow-control

    Weekly Downloads

    1

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • jandersonmartins