Inputs and outputs
Let the app that shows a design send data into your component and receive data from it.
On this page
Inputs and outputs connect a design to the app that shows it. An input receives data from the app. An output sends data to it. UI Builder lists them in Inputs / Outputs for every instance of your component. See Inputs and outputs.
Declare them
Declare the inputs and outputs in editor.html, for the list in the editor, and in render.html, for the published design:
exports.inputs = [{ id: 'set', name: 'Set value' }];
exports.outputs = [{ id: 'change', name: 'Change' }];The id of an input or output in the design is the id of the instance, _ and the id you declare, for example cid6wh0tx52_set.

Handle an input
instance.input('set', function(data, callback) {
instance.set('value', +data);
});The function receives the data and a callback. The app sends data with app.input():
app.input('cid6wh0tx52_set', 2, function(err) {
// err is 'Input "..." not found' when there is no such input
});Send an output
Pass the data to send it at once:
instance.output('change', value);Or register a function and call the output without data. UI Builder calls your function with next, and you send the result with next(err, data). Form sends its data this way:
instance.output('submit', function(next) {
next(null, instance.get());
});
instance.output('submit');Receive outputs in the app
The app that shows the design listens to the outputs of all instances:
app.on('output', function(meta) {
// meta.id 'cid6wh0tx52_change'
// meta.ref 'change'
// meta.data the data
// meta.err the error, or null
// meta.instance, meta.component, meta.app
});UIBuilder.on('output', fn) receives the outputs of every design on the page. See App reference.
Outputs of one instance
To give each instance its own outputs, for example one for each button the user adds, set instance.outputs to an array like exports.outputs. The editor lists those, and instance.output() uses them. App Layout does this for its buttons.
Send data to an input from a component
A component can send data to an input of the same design with instance.app.input(id, data). Button uses the input the user picks in its settings, from a field with dirsource:#inputs.