Class zebkit.DoIt | <zebkit> |
Promise-like sequential tasks runner (D-then). Allows developers to execute number of steps (async and sync) in the exact order they have been called with the class instance. The idea of the runner implementation is making the code more readable and plain nevertheless it includes asynchronous parts:
zebkit.DoIt
([ignore]
)
Parameters:
-
[ignore]
<Boolean>flag to rule error ignorance
Example:
var r = new zebkit.DoIt();
// step 1
r.then(function() {
// call three asynchronous HTTP GET requests to read three files
// pass join to every async. method to be notified when the async.
// part is completed
asyncHttpCall("http://test.com/a.txt", this.join());
asyncHttpCall("http://test.com/b.txt", this.join());
asyncHttpCall("http://test.com/c.txt", this.join());
})
. // step 2
then(function(r1, r2, r3) {
// handle completely read on previous step files
r1.responseText // "a.txt" file content
r2.responseText // "b.txt" file content
r3.responseText // "c.txt" file content
})
. // handle error
catch(function(e) {
// called when an exception has occurred
...
});
public | void | catch ([body]) |
public | void | error ([e]) |
public | <Function> | join ( ) |
public | void | restart ( ) |
public | void | then (body) |
public | void | throw ( ) |
public | void | till (r) |
public
chainable
catch ([body] )
Method to catch error that has occurred during the doit sequence execution. Parameters:
|
public
<Function>
join ( )
Returns join callback for asynchronous parts of the doit. The callback has to be requested and called by an asynchronous method to inform the doit the given method is completed.
Returns:
<Function>
a method to notify doit the given asynchronous part has been completed. The passed to the method arguments will be passed to the next step of the runner. * Example:
|
public
chainable
restart ( )
Restart the do it object to clear error that has happened and continue tasks that has not been run yet because of the error. |
public
chainable
then (body )
Run the given method as one of the sequential step of the doit execution. Parameters:
|
public
chainable
throw ( )
Throw an exception if an error has happened before the method call, otherwise do nothing. |
public
chainable
till (r )
Wait for the given doit redness. Parameters:
Example:
|