Function
A function is very similar to a template
except that instead of representing a single element, it can
represent n
elements. Because there is no 1-1 mapping of declaration to element, the api for function
is
more restricted than for template
and typography
. In particular, a function
cannot:
- Set Attributes
- Set Styles
- Use lifecycle handlers
- Use input event handlers
It can still declare parameters, state, slots, or any other member type that does not deal directly with a single element. Unlike
a template
or typography
, a function
is not valid without a render
block.
function SomeFunction {
required int count;
render {
repeat(i in count) {
Text("I am a function");
}
}
}