Action

Action

Base class for all actions

Constructor

new Action(name, options, concept)

Description:
  • Crate a new Action

Source:
Parameters:
Name Type Description
name string

The name of the action

options object

The options of the action

concept Concept

The owning concept

Methods

(async) apply(contexts, arguments) → {Promise.<Array.<VarvContext>>}

Description:
  • Applies this Action to the given contexts, returning some resulting contexts

Source:
Parameters:
Name Type Description
contexts Array.<VarvContext>
arguments object
Returns:
Type
Promise.<Array.<VarvContext>>

(async) forEachContext(contexts, actionArguments, callback) → {Promise.<Array.<VarvContext>>}

Description:
  • Loops through the given contexts, and calls the given callback for each, complete with substituted options and the index of the context

Source:
Parameters:
Name Type Description
contexts Array.<VarvContext>

The contexts to handle

actionArguments object

The arguments to use for this action

callback forEachCallback

The callback to call for each context

Returns:
Type
Promise.<Array.<VarvContext>>

(static) cloneContext(context) → {VarvContext}

Description:
  • Clones the given context. (Any non JSON serializable values in the context, will be lost)

Source:
Parameters:
Name Type Description
context VarvContext
Returns:
  • The cloned context
Type
VarvContext

(static) defaultVariableName(action) → {string}

Description:
  • Get the default variable name, for when no variable name is supplied

Source:
Parameters:
Name Type Description
action Action

The action asking, the name of the action is used.

Returns:
  • The default variable name
Type
string

(static) getCommonVariables(contexts) → {Object}

Description:
  • Extract all the variables that have the same value across all contexts

Source:
Parameters:
Name Type Description
contexts
Returns:
Type
Object

(static) getPrimitiveAction(name, options) → {Action}

Description:
  • Gets an instance of the primitive action with the given name, using the given options

Source:
Parameters:
Name Type Description
name string
options object
Returns:
Type
Action

(static) getVariable(context, name) → {any}

Description:
  • Retrieve the value of the given variable from the given context

Source:
Parameters:
Name Type Description
context VarvContext
name string
Returns:
Type
any

(static) hasPrimitiveAction(name) → {boolean}

Description:
  • Checks if a primitive action with the given name exists

Source:
Parameters:
Name Type Description
name string
Returns:
Type
boolean

(async, static) lookupArguments(options, actionArguments) → {object}

Description:
  • Looks up any options that are set to an argument replacement value "@myArgumentName" and replaces it with that arguments value

Source:
Parameters:
Name Type Description
options object

The options to do the replacement on

actionArguments object

The arguments to replace into the options

Returns:

A clone of the options argument, with all replacement values replaced

Type
object

(async, static) lookupVariables(options, context) → {object}

Description:
  • Look up any options that have a variable replacement value "$myVariable" and replaces it with the value of that variable.

Source:
Parameters:
Name Type Description
options object
context VarvContext
Returns:
  • Returns a clone of the given options, with all replacement values replaced.
Type
object

(static) registerPrimitiveAction(name, action)

Description:
  • Registers the given action as a primitive action with the given name

Source:
Parameters:
Name Type Description
name string
action Action

(static) setVariable(context, name, value)

Description:
  • Sets the given variable to the given value, in the given context

Source:
Parameters:
Name Type Description
context VarvContext

The context to set the variable inside

name string

The name of the variable to set

value any

The value to set