Although activity definitions are already defined as simple objects, one of the object's fields, getOutcomes, is actually a function. This makes it impossible to allow one to define activity definitions truly as data.
To fix this, I will change this field's type from a function to a union type of Array<string> | string. When the value is an array, each item is treated as a possible outcome. If the value is a string, it is interpreted as a lambda that will be evaluated at design-time in the designer.
Example using an array as outcomes:
{
"type": "WriteLine",
"displayName": "Write Line",
"description": "Writes a message to the standard output",
"category": "Console",
"outcomes": ["Done"]
}
When the lambda is evaluated, the designer will pass in the activity for which the outcomes are being requested. This is important for activities such as Fork, because it enables the user to define the possible branches from the designer. The lambda can use this information to yield the possible outcomes.
Although activity definitions are already defined as simple objects, one of the object's fields,
getOutcomes
, is actually a function. This makes it impossible to allow one to define activity definitions truly as data.To fix this, I will change this field's type from a
function
to a union type ofArray<string> | string
. When the value is an array, each item is treated as a possible outcome. If the value is a string, it is interpreted as a lambda that will be evaluated at design-time in the designer.Example using an array as outcomes:
Example using a lambda as outcomes:
When the lambda is evaluated, the designer will pass in the activity for which the outcomes are being requested. This is important for activities such as
Fork
, because it enables the user to define the possible branches from the designer. The lambda can use this information to yield the possible outcomes.