Nova · Actions
Counter
An action with count in its data and two triggers. A press on a button is a ui:click on its ref; the trigger for that ref changes the data, and the text over it is drawn again.
{
id: 'counter',
data: { count: 0 },
layout: {
component: 'Stack',
children: [
{ component: 'Text', children: 'Count: {{$.count}}' },
{
component: 'Button',
ref: 'more',
children: 'One more',
},
{
component: 'Button',
ref: 'fewer',
children: 'One fewer',
},
],
},
triggers: [
{
event: 'ui:click',
ref: 'more',
do: [{ increment: 'count' }],
},
{
event: 'ui:click',
ref: 'fewer',
do: [{ decrement: 'count' }],
},
],
}Count: 0
press more press more press fewer
{ count: 1 }Count: 1 One more One fewer
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.