Nova · Actions
List
push adds to the end of a list and removeAt takes out the element at a position. The loop over the list follows.
{
id: 'list',
data: { guests: ['Ada', 'Grace'] },
layout: {
component: 'Stack',
children: [
{
for: '$.guests',
as: 'guest',
do: { component: 'Text', children: '$guest' },
},
{
component: 'Button',
ref: 'add',
children: 'Add Linus',
},
{
component: 'Button',
ref: 'first',
children: 'Remove the first',
},
],
},
triggers: [
{
event: 'ui:click',
ref: 'add',
do: [{ push: 'guests', value: 'Linus' }],
},
{
event: 'ui:click',
ref: 'first',
do: [{ removeAt: 'guests', index: 0 }],
},
],
}Ada
Grace
press add press first
{ guests: ['Grace', 'Linus'] }Grace Linus Add Linus Remove the first
Left: the action as the package ships it. Right: the same action running in this page, rendered with this site’s components. Below: the action run as the example specifies, on the installed package.