Nodes
Array Push#
The Array Push node allows you to add one or more items to the end of an array. It is useful when you need to dynamically build or extend an array based on inputs or conditions in your spell.
Inputs#
array(array): The input array to which items will be pushed. If left disconnected, the node will create a new empty array.flow(flow): The flow input triggers the node to execute and push items to the array.Item(any): One or more sockets representing the items to be pushed to the array. The number of sockets is dynamically determined by thesocketInputsconfiguration.
Outputs#
flow(flow): The flow output is triggered after the items have been pushed to the array.array(array): The updated array with the new items pushed to the end.
Configuration#
valueType(string): Specifies the data type of the items being pushed to the array. Choose from "string", "number", "float", "boolean", "object", or "array". Leave blank to allow any data type.socketInputs(array): Defines the number and names of the input sockets for the items to be pushed. Each element in the array represents a socket. For example,["item1", "item2"]will create two input sockets named "item1" and "item2".
Instructions#
- Connect an input array to the 
arrayinput socket. If left disconnected, a new empty array will be created. - Connect the items you want to push to the array to the dynamically created input sockets (e.g., "Item").
 - Configure the 
valueTypeto specify the data type of the items being pushed (optional). - Configure the 
socketInputsarray to define the number and names of the item input sockets (optional). - Connect a flow to the 
flowinput socket to trigger the node's execution. - The updated array with the pushed items will be available at the 
arrayoutput socket. 
Example#
Suppose you have a spell that collects user information from various sources and you want to consolidate the data into a single array. You can use the Array Push node to achieve this:
- Create an empty array using the Create Array node.
 - Connect the empty array to the 
arrayinput of the Array Push node. - Configure the 
socketInputsto["name", "email", "age"]to create three input sockets for the user's name, email, and age. - Connect the user's name, email, and age data to the corresponding input sockets of the Array Push node.
 - Connect a flow to the 
flowinput to trigger the node's execution. - The updated array containing the user's information will be available at the 
arrayoutput. 
Best Practices#
- Ensure that the data types of the items being pushed match the specified 
valueType(if configured) to avoid type mismatches. - Use meaningful names for the 
socketInputsto improve the readability of your spell. - If pushing a large number of items, consider using a loop or a separate spell to avoid creating too many input sockets.
 
Common Issues#
- If the 
valueTypeis configured and the data type of an item being pushed does not match, the node will throw an error. - If the 
arrayinput is left disconnected and no items are pushed, the node will output an empty array. 
By using the Array Push node, you can easily add items to an array dynamically, making it a versatile tool for building and manipulating arrays in your Magick spells.