src/aria/core/JsObject.js
function (cb, res, errorId) {
                try {
                    if (!cb) {
                        return; // callback is sometimes not used
                    }

                    if (cb.$Callback) {
                        return cb.call(res);
                    }

                    // perf optimisation : duplicated code on purpose
                    var scope = cb.scope, callback;
                    scope = scope ? scope : this;
                    if (!cb.fn) {
                        callback = cb;
                    } else {
                        callback = cb.fn;
                    }

                    if (typeof(callback) == 'string') {
                        callback = scope[callback];
                    }

                    var args = (cb.apply === true && cb.args && Object.prototype.toString.apply(cb.args) === "[object Array]")
                            ? cb.args.slice()
                            : [cb.args];
                    var resIndex = (cb.resIndex === undefined) ? 0 : cb.resIndex;

                    if (resIndex > -1) {
                        args.splice(resIndex, 0, res);
                    }

                    return Function.prototype.apply.call(callback, scope, args);
                } catch (ex) {
                    this.$logError(errorId || this.CALLBACK_ERROR, [this.$classpath, (scope) ? scope.$classpath : ""], ex);
                }
            }
function (cb, res, errorId) {
                try {
                    if (!cb) {
                        return; // callback is sometimes not used
                    }

                    if (cb.$Callback) {
                        return cb.call(res);
                    }

                    // perf optimisation : duplicated code on purpose
                    var scope = cb.scope, callback;
                    scope = scope ? scope : this;
                    if (!cb.fn) {
                        callback = cb;
                    } else {
                        callback = cb.fn;
                    }

                    if (typeof(callback) == 'string') {
                        callback = scope[callback];
                    }

                    var args = (cb.apply === true && cb.args && Object.prototype.toString.apply(cb.args) === "[object Array]")
                            ? cb.args.slice()
                            : [cb.args];
                    var resIndex = (cb.resIndex === undefined) ? 0 : cb.resIndex;

                    if (resIndex > -1) {
                        args.splice(resIndex, 0, res);
                    }

                    return Function.prototype.apply.call(callback, scope, args);
                } catch (ex) {
                    this.$logError(errorId || this.CALLBACK_ERROR, [this.$classpath, (scope) ? scope.$classpath : ""], ex);
                }
            }
function ( cb , res , errorId ) { try { if ( ! cb ) { return ; // callback is sometimes not used } if ( cb . $Callback ) { return cb . call ( res ) ; } // perf optimisation : duplicated code on purpose var scope = cb . scope , callback ; scope = scope ? scope : this ; if ( ! cb . fn ) { callback = cb ; } else { callback = cb . fn ; } if ( typeof ( callback ) == 'string' ) { callback = scope [ callback ] ; } var args = ( cb . apply === true && cb . args && Object . prototype . toString . apply ( cb . args ) === "[object Array]" ) ? cb . args . slice ( ) : [ cb . args ] ; var resIndex = ( cb . resIndex === undefined ) ? 0 : cb . resIndex ; if ( resIndex > - 1 ) { args . splice ( resIndex , 0 , res ) ; } return Function . prototype . apply . call ( callback , scope , args ) ; } catch ( ex ) { this . $logError ( errorId || this . CALLBACK_ERROR , [ this . $classpath , ( scope ) ? scope . $classpath : "" ] , ex ) ; } }
Generic method allowing to call-back a caller in asynchronous processes
@param {aria.core.CfgBeans:Callback} cb callback description
@param {MultiTypes} res first result argument to pass to cb.fn (second argument will be cb.args)
@param {String} errorId error raised if an exception occurs in the callback
@return {MultiTypes} the value returned by the callback, or undefined if the callback could not be
called.
Generic method allowing to call - back a caller in asynchronous processes