Functions and Events
Last updated
Was this helpful?
Last updated
Was this helpful?
In Midio, functions take input from the left and provide output on the right. Unlike most programming languages, such as JavaScript, Python, or C, Midio functions can produce multiple outputs. Functions in Midio are similar to those in other languages, and they form alongside events the core components of the language. Almost every node in Midio is either a function or an event. For information the builtin functions and events in Midio, refer to the .
Some functions and events also has triggers, which are the green sockets. Functions with triggers need to be explicitly 'triggered' in order to be called, while non-triggable functions (functions without any triggers), are called 'on-demand', if connected to a node that is called.
You can easily make your own functions, either by selecting a group of nodes and using 'Convert to Function' from the right-click/context menu, or by right clicking a module in the modules over view and clicking 'Add function here'.
You can add inputs and output, either through the node-menu (space bar), or by control-clicking the canvas while your adding a new arrow. This will automatically add a new input/output to your function, and hook it up to the arrow you started.
TODO: Screen capture
Events have a green header, and never any input triggers.
Triggers don't require much setup to use, but can optionally declare what context they consume or borrow (for inputs) or produce (for outputs). Contexts is a slightly advanced topic that you can read more about .
Data inputs can be assigned a type, if you want to be specific about the kinds of data it expects. If you don't care about the type, assign it to the Any
type. Use the dropdown menu on the input/output node to assign a new type.
Events are used to trigger flows, based on a variety of external conditions, like receiving an , or on a .