Intents
Use widgetIntents for user-triggered actions from buttons.
Rules
- Register intent functions under
widgetIntents. - Generate
intentvalues from the object returned byAwait.define. - Intent parameters must be encodable values: strings, numbers, booleans,
undefined, arrays, or plain objects containing encodable values.
Example
tsx
import {Button, Text, VStack} from 'await';
function add(step: number) {
const count = AwaitStore.num('count', 0);
AwaitStore.set('count', count + step);
}
function widget() {
const count = AwaitStore.num('count', 0);
return (
<VStack spacing={8} maxSides padding={16}>
<Text value={count} fontSize={28}/>
<Button intent={app.add(1)}>
<Text value='Add'/>
</Button>
</VStack>
);
}
const app = Await.define({
widget,
widgetIntents: {add},
});Animation Notes
- Use stable
idvalues for visual entities that move or animate. - Widget animation duration is capped at 2 seconds.
- For moving entities, prefer a stable outer shell with
idandoffset. - Do not put
offsetandtransition='scale'on the same node.