1 Observables
An observable holds a value, where the value in an observable can be updated, and graphical elements can react automatically to update. For example, the label or enable state for a button can be supplied as an observable, and if the obervable’s value changes, then the graphical representation of the button changes automatically to match.
An observable corresponds to #{obs?} from racket/gui/easy.
class | ||||
| ||||
| ||||
annotation | ||||
| ||||
| ||||
annotation | ||||
| ||||
| ||||
annotation | ||||
| ||||
| ||||
annotation | ||||
| ||||
| ||||
annotation | ||||
| ||||
| ||||
annotation | ||||
|
The annotation Obs.of(annot) is satisfied by an annotation whose value satisfies annot. The predicate and conversion (if any) associated with annot is not applied immediately, but it is applied every time a value is extracted or put into the observable. The annotation ObsOrValue.of(annot) is satisfied by a value that satisfies either annot or Obs.of(annot).
The Obs.now_of(annot) annotation is Obs.of(annot), but the current value in the observable is checked immediately, and it is not checked later or when a new value is supplied to the observable. In other words, Obs.now_of(annot) is a predicate annotation, while Obs.of(annot) is a converter annotation. The annot argument in Obs.now_of(annot) must be a predicate annotation. The ObsOrValue.now_of(annot) annotation is analogously like ObsOrValue.of(annot).
The Obs.later_of(annot) and ObsOrValue.later_of(annot) annotations are aliases for Obs.of(annot) and ObsOrValue.of(annot), respectively.
method | ||
| ||
operator | ||
Normally, instead of peeking an observable’s value, you should either register an observer or pass an observer to a constructor that expects one. For example, when an observer’s value should affect drawing in a Canvas, then the first argument to Canvas should the observer (or one derived from it), and then a rendered canvas will be updated when the observable changes.
method | ||
| ||
operator | ||
function | ||
| ||
function | ||
|