No description, website, or topics provided.
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
lib
test
.gitignore
README.md

README.md

Diner.js

Description

DinerJs is a flowcontrol library, is the core of Orim, is part of LokiJs. With Diner yo can chain asincronous functions and sincronous functions easy, check the value of the operations at any time and listen to every function been completed, errors and when the queue is empty.

Example

var diner = new Diner();

//Define your functions
diner.define('asyncAritmeticAddition',function(){
    var value = this.getValue();
    var deferal = new Loki.Deferal();

    process.nextTick(function () {
        deferal.resolve(value + n);
    });

    return deferal.promise;         
});

diner.define('syncAritmeticAddition', function(n){
    var value = this.getValue();
    return  n + value;
});

//Use your function
diner.asyncAritmeticAddition(10)
 .syncAritmeticAddition(5)
 .asyncAritmeticAddition(5)
 .syncAritmeticAddition(10);

//Check the value
diner.getValue();

##Usage

Browser

<<script type="text/javascript">
    window.Loki = {}
</script>
<script src="../lib/Promise.js" type="text/javascript"></script>
<script src="../lib/Diner.js" type="text/javascript"></script>

Node

npm install Diner

var Diner = require('Diner').Diner

##API

####Init

var diner = new Diner();

#####Basic

  • add
  • define

#####Events

  • onComplete
  • onNextComplete
  • onErrorComplete
  • onEmptyComplete

Note: All functions in diner return diner himself, so its you can chain them.

diner.onComplete(function(){
    //.. something
}).add(function(){
    //.. something else
})