cables_dev/cables/src/core/core_variable.js
import { Events } from "cables-shared-client";
/**
* @type {Object}
* @name PatchVariable
* @param {String} name
* @param {String|Number} value
* @memberof Patch
* @constructor
*/
class PatchVariable extends Events
{
constructor(name, val, type)
{
super();
this._name = name;
this.type = type;
this.setValue(val);
}
/**
* keeping this for backwards compatibility in older
* exports before using eventtarget
*
* @param cb
*/
addListener(cb)
{
this.on("change", cb, "var");
}
/**
* @function Variable.getValue
* @memberof PatchVariable
* @returns {String|Number|Boolean}
*/
getValue()
{
return this._v;
}
/**
* @function getName
* @memberof PatchVariable
* @instance
* @returns {String|Number|Boolean}
* @function
*/
getName()
{
return this._name;
}
/**
* @function setValue
* @memberof PatchVariable
* @instance
* @param v
* @returns {String|Number|Boolean}
* @function
*/
setValue(v)
{
this._v = v;
this.emitEvent("change", v, this);
}
}
export default PatchVariable;