Node()
Node class
Extends
EventEmitter
Synopsis
{Node} =
new Node();
node.data
An object map which contains all data coming from the editor, combined with the data from the vault. Preferred way of addressing this data is making use of the node.getData() method.
Event: node "init"
Init event which is applied to all nodes, when the flow starts.
Parameters
name | type | description |
---|---|---|
state | FlowState | The initial (blank) state of the flow. |
Synopsis
node.on('init', (
{FlowState} state
) => {});
Event: node "trigger"
Trigger event which is applied to event nodes when the flow starts, after all nodes have received the init event.
Parameters
name | type | description |
---|---|---|
state | FlowState | A blank state, equal to the state provided on the init event. |
Synopsis
node.on('trigger', (
{FlowState} state
) => {});
node.addProgressBar(status)
Adds a progress bar to the node, visible in the editor.
Parameters
name | type | required | default | description |
---|---|---|---|---|
status | Object | yes | ||
status.message | String | no | A text message representing the context of the progress bar. | |
status.percentage | Number | no | 0 | The starting point of the progress bar as a percentage. Value can range from 0 to (including) 100. |
status.updateOverTime | Number | no | Specifies the time in milliseconds to automatically update the progress bar to 100% from the given percentage value. | |
status.timeout | Number | no | Timeout in milliseconds after which the progress bar disappears. |
Returns
Returns an identifier, which can be used to update the status of the progress bar through node.updateProgressBarById, or remove the progress bar through removeProgressBarById.
Synopsis
{Number} =
node.addProgressBar(
{Object} status,
{String} status.message,
{Number} status.percentage,
{Number} status.updateOverTime,
{Number} status.timeout
);
node.addStatus(status)
Adds a status message to a node, visible in the editor.
Parameters
name | type | required | default | description |
---|---|---|---|---|
status | Object | yes | ||
status.message | String | yes | Text message to show. | |
status.color | String | no | Color for the indicator next to the text message. If none provided, the CSS file of the editor decides on a appropriate default color. | |
status.timeout | String | no | Timeout in milliseconds before the message should disappear. If none provided, the message will remain until the flow is stopped or this status is removed by calling removeStatusById(). |
Returns
Returns an identifier, which can be used to update the status through node.updateStatusById, or remove it through removeStatusById.
Synopsis
{Number} =
node.addStatus(
{Object} status,
{String} status.message,
{String} status.color,
{String} status.timeout
);
node.error(err, state)
Throws an error, with the current state and node appended to the Error object. Calls setTracker() on the node with the error message. If the flowInstance contains an "error" event listener, the flow will not stop, unless thrown more than once. This behaviour is demonstrated by including a "xible.flow.instance.on-error" node in the flow. The differences between regular throwing and this method include; * The current state is appended to the Error object. * The current node is appended to the Error object. * setTracker is invoked so the editor can visualize where the error originated.
Parameters
name | type | required | default | description |
---|---|---|---|---|
err | Error | yes | An error object to raise. | |
err.state | FlowState | yes | Flowstate at point of the error. Either this or the state argument should be provided. | |
state | FlowState | yes | Flowstate at point of the error. Either this or the err.state argument should be provided. |
Synopsis
node.error(
{Error} err,
{FlowState} err.state,
{FlowState} state
);
node.getData(dataName, state)
Fetches all input values for this input.
Parameters
name | type | required | default | description |
---|---|---|---|---|
dataName | String | yes | The data name to fetch the values for. | |
state | FlowState | yes | The flowstate at the time of calling. |
Returns
An array of all values related to this data field. This includes the form field (first value), and data fetched from a related input. If a related input is configured, the input data is added to the returned array, unless 'replaces' is configured to true on the input configuration. If 'replaces' is set to true, the form field is ignored. For related inputs, data is returned by the outputs on the other ends of connected connectors or globals. If any of the outputs returns an array, it will be concatened to the return array, instead of pushed.
Synopsis
{Promise.<Array>} =
node.getData(
{String} dataName,
{FlowState} state
);
node.getInputByName(name)
Returns an input by the given name, or null if it does not exist.
Parameters
name | type | required | default | description |
---|---|---|---|---|
name | String | yes | Name of the input. |
Returns
An input, or null if not found.
Synopsis
{NodeInput | null} =
node.getInputByName(
{String} name
);
node.getInputs()
Returns all inputs attached to this node.
Returns
List of inputs.
Synopsis
{Array.<NodeInput>} =
node.getInputs();
node.getOutputByName(name)
Returns an output by the given name, or null if it does not exist.
Parameters
name | type | required | default | description |
---|---|---|---|---|
name | String | yes | Name of the output. |
Returns
An output, or null if not found.
Synopsis
{NodeOutput | null} =
node.getOutputByName(
{String} name
);
node.getOutputs()
Returns all outputs attached to this node.
Returns
List of outputs.
Synopsis
{Array.<NodeOutput>} =
node.getOutputs();
node.hasConnectedInputsOfType(type)
Confirms whether the node has any inputs of the given type.
Parameters
name | type | required | default | description |
---|---|---|---|---|
type | String | null | yes | The type you want to check. Null would be "any" type. |
Returns
Returns a Boolean; true or false.
Synopsis
{Boolean} =
node.hasConnectedInputsOfType(
{String | null} type
);
node.removeAllStatuses()
Removes all statuses and progress bars for a node, immediately.
Synopsis
node.removeAllStatuses();
node.removeProgressBarById(statusId, timeout)
Removes a progress bar referred to by it sidentifier. Alias for removeStatusById().
Parameters
name | type | required | default | description |
---|---|---|---|---|
statusId | Number | yes | Identifier of the progress bar to remove. | |
timeout | Number | no | The amount of time in milliseconds before actually removing the progress bar. |
Synopsis
node.removeProgressBarById(
{Number} statusId,
{Number} timeout
);
node.removeStatusById(statusId, timeout)
Removes a status referred to by it sidentifier.
Parameters
name | type | required | default | description |
---|---|---|---|---|
statusId | Number | yes | Identifier of the status to remove. | |
timeout | Number | no | The amount of time in milliseconds before actually removing the status. |
Synopsis
node.removeStatusById(
{Number} statusId,
{Number} timeout
);
node.setTracker(status)
Overwrites the tracker message. This message is visible above a node in the editor, and usually used to show when the node got triggered.
Parameters
name | type | required | default | description |
---|---|---|---|---|
status | Object | yes | ||
status.message | String | yes | Text message to show. | |
status.color | String | no | Color for the indicator next to the text message. If none provided, the CSS file of the editor decides on a appropriate default color. |
Synopsis
node.setTracker(
{Object} status,
{String} status.message,
{String} status.color
);
node.setTypeDef(constr, type)
Relates the given typeDef to a javascript Constructor. This allows XIBLE to filter input values based on type in the extends chain.
Parameters
name | type | required | default | description |
---|---|---|---|---|
constr | Constructor | yes | The constructor to relate the typeDef to. | |
type | String | TypeDef | yes | Type to relate to the constructor. |
Synopsis
node.setTypeDef(
{Constructor} constr,
{String | TypeDef} type
);
node.updateProgressBarById(statusId, status)
Updates the status on an existing progress bar.
Parameters
name | type | required | default | description |
---|---|---|---|---|
statusId | Number | yes | The identifier of the existing progress bar, as returned by addProgressBar(). | |
status | Object | yes | ||
status.percentage | Number | yes | The point of the progress bar as a percentage. Value can range from 0 to (including) 100. |
Returns
Returns the given statusId.
Synopsis
{Number} =
node.updateProgressBarById(
{Number} statusId,
{Object} status,
{Number} status.percentage
);
node.updateStatusById(statusId, status)
Updates the status on an existing status.
Parameters
name | type | required | default | description |
---|---|---|---|---|
statusId | Number | yes | The identifier of the existing status, as returned by addStatus(). | |
status | Object | yes | ||
status.message | String | yes | Text message to show. | |
status.color | String | no | Color for the indicator next to the text message. If none provided, the CSS file of the editor decides on a appropriate default color. |
Returns
Returns the given statusId.
Synopsis
{Number} =
node.updateStatusById(
{Number} statusId,
{Object} status,
{String} status.message,
{String} status.color
);
Node.flowStateCheck(state)
Static. Asserts that the given status is a FlowState
Parameters
name | type | required | default | description |
---|---|---|---|---|
state | FlowState | yes |
Returns
Always returns true if not thrown.
Synopsis
{Boolean} =
Node.flowStateCheck(
{FlowState} state
);