watch method

SamWatch watch (
  1. BuildFunc bf
)

Establish a watch scope and return a SamWatch widget.

This is used to allow child portions of the Widget tree to be monitored so that the Widget rendering is more efficient. Any variable in SamHot that is read within this scope is watched for changes. If the value changes a Widget build function is triggered at this level (which will rebuild child widgets).

This is useful for example in the Rocket sample application where the counter is updated.

For form type widgets its requirement is variable. TextField widgets automatically update the field they represent and so it so not required. The Picker type widgets do not and therefore, if they do not cause a state change, a SamWatch may be required.

The samwig set of Widgets are designed and coded with this understanding in view.

Implementation

SamWatch watch(BuildFunc bf) {
  return SamWatch(bf,this);
}