Options
All
  • Public
  • Public/Protected
  • All
Menu

Command provides a general purpose, loosely coupled command model. A command can have 0 or more implementations registered to it.

Hierarchy

  • Command

Implements

Index

Constructors

constructor

  • Initializes a new instance of the Command class.

    Parameters

    • name: string

      The name of this command.

    • app: Application

      The {@link application.Application} that this command belongs to.

    • Optional canExecuteMode: string

      An optional string, either any or all. A canExecuteMode of any will prevent the command from running if any of the constituent implementations return false in their canExecute delegate. A canExecuteMode of all (the default) will only prevent the command from running if all of the constituent canExecute delegates return false.

    Returns Command

Events

canExecuteChanged

canExecuteChanged: GeocortexEvent

Event raised when the command's can execute status may have changed.

Properties

app

The {@link geocortex.framework.application.Application} that this command instance belongs to.

canExecuteMode

canExecuteMode: string

Execute mode for the command. One of:

  • all<
  • any

isWrapper

isWrapper: boolean

Whether this command is a wrapper command or not. A wrapper command is one that has been created as a result of something trying to execute it, despite not having been created previously.

name

name: string

The name of this command.

postExecute

postExecute: GeocortexEvent

Event raised when execute has been called on the command and at least one implementation has executed.

preExecute

preExecute: GeocortexEvent

Event raised when execute has been called on the command and at least one implementation is about to execute.

Methods

canExecute

  • canExecute(...parameters: any[]): boolean
  • Returns true or false based on whether this command can execute or not. In the case of a canExecute triggering a deferred module load this will return false initially, but 'raiseCanExecuteChanged' will be called after the module loads.

    Parameters

    • Rest ...parameters: any[]

      0 or more parameters to evaluate canExecute with.

    Returns boolean

clear

  • clear(): void
  • Clears this command of all implementations.

    Returns void

execute

  • execute(...parameters: any[]): void
  • Executes this command. If multiple implementations have been registered, they are executed sequentially.

    Parameters

    • Rest ...parameters: any[]

      0 or more parameters to pass to the command.

    Returns void

raiseCanExecuteChanged

  • raiseCanExecuteChanged(): void

register

  • Registers a command implementation that executes in a specific scope and with optional canExecute logic.

    Parameters

    • scope: any

      The scope of which to execute the command implementation.

    • implementation: FunctionReturning<void>

      The implementation to add to this command/

    • Optional canExecute: FunctionReturning<boolean>

      An optional canExecute method to decide whether this command fragment can execute or not.

    Returns string

unregister

  • unregister(token: string): boolean
  • Removes a command implementation from this command, using the token returned when the implementation was registered.

    Parameters

    • token: string

      The token that was returned when the command implementation was registered.

    Returns boolean