Nova · Actions

Set from

set with from copies what stands at one path to another. Here every step first keeps the count it is about to change, so one press takes it back.

The action, as it is written
{
  id: 'set-from',
  data: { count: 1, before: 1 },
  layout: {
    component: 'Stack',
    children: [
      { component: 'Text', children: 'Seats: {{$.count}}' },
      {
        component: 'Button',
        ref: 'more',
        children: 'One more',
      },
      { component: 'Button', ref: 'undo', children: 'Undo' },
    ],
  },
  triggers: [
    {
      event: 'ui:click',
      ref: 'more',
      do: [
        { set: 'before', from: 'count' },
        { increment: 'count' },
      ],
    },
    {
      event: 'ui:click',
      ref: 'undo',
      do: [{ set: 'count', from: 'before' }],
    },
  ],
}
Running herepress it

Seats: 1

What is done to it
press more
press more
press undo
What it then holds
{ count: 2, before: 2 }
What it then says
Seats: 2
One more
Undo
Output matches the expected value

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.