Accessing primitives
Most Arez users will make use of annotations to define the reactive components required for their application.
For most applications, most of the time, this is sufficient. Very occasionally it is useful to get access to the
underlying primitives. This could mean getting access to the ObservableValue
instance for
an @Observable
property, getting access to the ComputableValue
instance for a
@Memoize
property etc. It could also be accessing information about the component such
as the component name or the components type name. Access to the underlying primitives is needed for some reactive
features (i.e. explicit calls to Observer.schedule()
to manually schedule
observers or Observer.reportStale()
/ComputableValue.reportPossiblyChanged()
when non-arez dependencies are included in the system). However another significant reason is to enable integration
with framework specific DevTools.
Accessing these these primitives is made possible through the user of the @*Ref
annotations. The @*Ref
annotations are placed on accessor methods that return the appropriate primitive. Some of these @*Ref
annotations
rely on either the accessors being named appropriately or on a name field aligning with the corresponding
primitives name. i.e. The @ObservableValueRef
must set the name
parameter to the same value as
the associated @Observable
property name. Alternatively the name for the
@ObservableValueRef
annotation can be derived from the accessor name if it is named according to
the pattern get[Name]ObservableValue
. See the javadocs for the individual annotation requirements.
The @*Ref
annotations include the following:
@ComponentNameRef
: This method exposes the underlying name of the component.@ComponentIdRef
: This method exposes the underlying id of the component.@ComponentTypeNameRef
: This method exposes the underlying name of the component type.@ObservableValueRef
: This method exposes the underlyingObservableValue
for an@Observable
property.@ComputableValueRef
: This method exposes the underlyingComputableValue
for a@Memoize
property.@ObserverRef
: This method exposes the underlyingObserver
for the@Observe
annotated method.@ContextRef
: This method exposes theArezContext
that the component is contained within.@ComponentRef
: This method exposes the nativeComponent
associated with the component. This method should NOT be invoked unless native components are enabled. See the Native Components section of the documentation to understand how native components are enabled.