123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- define([
- '../Core/defined',
- '../Core/defineProperties',
- '../Core/DeveloperError',
- '../Core/Event'
- ], function(
- defined,
- defineProperties,
- DeveloperError,
- Event) {
- "use strict";
-
- var CallbackProperty = function(callback, isConstant) {
- this._callback = undefined;
- this._isConstant = undefined;
- this._definitionChanged = new Event();
- this.setCallback(callback, isConstant);
- };
- defineProperties(CallbackProperty.prototype, {
-
- isConstant : {
- get : function() {
- return this._isConstant;
- }
- },
-
- definitionChanged : {
- get : function() {
- return this._definitionChanged;
- }
- }
- });
-
- CallbackProperty.prototype.getValue = function(time, result) {
- return this._callback(time, result);
- };
-
- CallbackProperty.prototype.setCallback = function(callback, isConstant) {
-
- if (!defined(callback)) {
- throw new DeveloperError('callback is required.');
- }
- if (!defined(isConstant)) {
- throw new DeveloperError('isConstant is required.');
- }
-
- var changed = this._callback !== callback || this._isConstant !== isConstant;
- this._callback = callback;
- this._isConstant = isConstant;
- if (changed) {
- this._definitionChanged.raiseEvent(this);
- }
- };
-
- CallbackProperty.prototype.equals = function(other) {
- return this === other || (other instanceof CallbackProperty && this._callback === other._callback && this._isConstant === other._isConstant);
- };
-
- return CallbackProperty;
- });
|