Computed Properties
A computed property is a read only method which can be extruded like a value. You can think of it like a C# get-only property.
Computed properties are public by default but can be annotated with :private
to make them only visible inside the defining template. They
cannot be used with a from
mapping but do have access to any top level field declaration.
template ComputedPropertyExample {
state int x;
state int y;
computed int sum => x + y;
// only visible inside this template's definition
computed:private int product => x + y;
}
template UsingAComputedProperty render {
// a computed property can be extruded with the [] operator
ComputedPropertyExample() [sum]
Text($"x + y is {sum}");
}