Command.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*global define*/
  2. define([
  3. '../Core/DeveloperError'
  4. ], function(
  5. DeveloperError) {
  6. "use strict";
  7. /**
  8. * A Command is a function with an extra <code>canExecute</code> observable property to determine
  9. * whether the command can be executed. When executed, a Command function will check the
  10. * value of <code>canExecute</code> and throw if false.
  11. *
  12. * This type describes an interface and is not intended to be instantiated directly.
  13. * See {@link createCommand} to create a command from a function.
  14. *
  15. * @alias Command
  16. * @constructor
  17. */
  18. var Command = function() {
  19. /**
  20. * Gets whether this command can currently be executed. This property is observable.
  21. * @type {Boolean}
  22. * @default undefined
  23. */
  24. this.canExecute = undefined;
  25. /**
  26. * Gets an event which is raised before the command executes, the event
  27. * is raised with an object containing two properties: a <code>cancel</code> property,
  28. * which if set to false by the listener will prevent the command from being executed, and
  29. * an <code>args</code> property, which is the array of arguments being passed to the command.
  30. * @type {Event}
  31. * @default undefined
  32. */
  33. this.beforeExecute = undefined;
  34. /**
  35. * Gets an event which is raised after the command executes, the event
  36. * is raised with the return value of the command as its only parameter.
  37. * @type {Event}
  38. * @default undefined
  39. */
  40. this.afterExecute = undefined;
  41. DeveloperError.throwInstantiationError();
  42. };
  43. return Command;
  44. });