ARCS logo.js Augmented Reality Component System

Source: invocation.js

/******************************************************************************
 * Invocation implementation
 * ***************************************************************************/
/**
 * Defines an invocation
 * @param destination {object} component on which to perform invocation
 * @param slot {string} name of the slot 
 * @param value {mixed} value passed to the invoked slot
 * @constructor
 */
ARCS.Invocation = function (destination, slot, value) {
    this.invoke = function () {
        var func = destination[slot];
        func.apply(destination, value);
    };
};
/**
 * Helper function that casts an invocation from a description 
 * @param obj {object} a raw description of the invocation
 * @param context {object} the context in which this invocation takes place.
 * @return an invocation
 */
ARCS.Invocation.cast = function (obj, context) {
    return new ARCS.Invocation(context[obj.destination], obj.slot, obj.value);
};