A collection of language helpers.
Methods
(static) collect(chain, callbacknullable, scopenullable)
Executes a chain of functions
in parallel. It is used where several
asynchronous calls are not interdependent but do share a blocking
condition.
The functions
in chain
should each accept an empty callback function
as their first and only parameter and invoke this callback on completion.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
chain |
Array.<module:mendix/lang~ChainCallback> | array of functions to execute in parallel |
|
callback |
function |
<nullable> |
function to execute at the end of the chain |
scope |
Object |
<nullable> |
object in which scope to execute the functions in |
Example
lang.collect([
function(callback) {
setTimeout(callback, 100); // async
},
function(callback) {
setTimeout(callback, 100); // async
},
function(callback) {
setTimeout(callback, 100); // async
}
], function() {
console.log("Completed");
}, this);
(static) getUniqueId() → {string}
Returns a unique identifier
Returns:
unique identifier
- Type
- string
(static) sequence(chain, callbacknullable, scopenullable)
Executes a chain of functions
in sequence. It is used to sequence the
execution of both synchronous and asynchronous calls.
The functions
in chain
should each accept an empty callback function
as their first and only parameter and invoke this callback on completion.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
chain |
Array.<module:mendix/lang~ChainCallback> | array of functions to execute in sequence |
|
callback |
function |
<nullable> |
function to execute at the end of the chain |
scope |
Object |
<nullable> |
object in which scope to execute the functions in |
Example
lang.sequence([
function(callback) {
callback(); // sync
},
function(callback) {
setTimeout(callback, 100); // async
}
], function() {
console.log("Completed");
}, this);
Type Definitions
ChainCallback(callback)
Callback for functions to be called in a chain.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | invoke this function on completion |