js/clients/SparkCore.js
function (name, type, callback) {
        var that = this;
        var performRequest = function () {
            if (!that.HasSparkVariable(name)) {
                callback(null, null, "Variable not found");
                return;
            }

            var token = this.sendMessage("VariableRequest", { name: name });
            var varTransformer = this.transformVariableGenerator(name, callback);
            this.listenFor("VariableValue", null, token, varTransformer, true);
        }.bind(this);

        if (this.hasFnState()) {
            //slight short-circuit, saves ~5 seconds every 100,000 requests...
            performRequest();
        }
        else {
            when(this.ensureWeHaveIntrospectionData())
                .then(
                    performRequest,
                    function (err) { callback(null, null, "Problem requesting variable: " + err);
                });
        }
    }
function (name, type, callback) {
        var that = this;
        var performRequest = function () {
            if (!that.HasSparkVariable(name)) {
                callback(null, null, "Variable not found");
                return;
            }

            var token = this.sendMessage("VariableRequest", { name: name });
            var varTransformer = this.transformVariableGenerator(name, callback);
            this.listenFor("VariableValue", null, token, varTransformer, true);
        }.bind(this);

        if (this.hasFnState()) {
            //slight short-circuit, saves ~5 seconds every 100,000 requests...
            performRequest();
        }
        else {
            when(this.ensureWeHaveIntrospectionData())
                .then(
                    performRequest,
                    function (err) { callback(null, null, "Problem requesting variable: " + err);
                });
        }
    }
function ( name , type , callback ) { var that = this ; var performRequest = function ( ) { if ( ! that . HasSparkVariable ( name ) ) { callback ( null , null , "Variable not found" ) ; return ; } var token = this . sendMessage ( "VariableRequest" , { name : name } ) ; var varTransformer = this . transformVariableGenerator ( name , callback ) ; this . listenFor ( "VariableValue" , null , token , varTransformer , true ) ; } . bind ( this ) ; if ( this . hasFnState ( ) ) { //slight short-circuit, saves ~5 seconds every 100,000 requests... performRequest ( ) ; } else { when ( this . ensureWeHaveIntrospectionData ( ) ) . then ( performRequest , function ( err ) { callback ( null , null , "Problem requesting variable: " + err ) ; } ) ; } }
Ensures we have introspection data from the core, and then
requests a variable value to be sent, when received it transforms
the response into the appropriate type
@param name
@param type
@param callback - expects (value, buf, err)
Ensures we have introspection data from the core and then requests a variable value to be sent when received it transforms the response into the appropriate type