Annotation Interface AutoObserve


Methods and fields annotated by this annotation should be observed for the alive lifetime of the component.

This annotation is typically used when a field references an ArezComponent annotated class that has ArezComponent.disposeOnDeactivate() set to true. This results in the current component observing the referenced component and thus preventing it from being disposed for the lifetime of the current component.

It should be noted that it is preferable for the field that defines the observed component to be marked with this annotation rather than the method accessor. The reason is that the annotation processor will issue a warning if a field that the processor identifies as a potential dependency if it is not annotated with AutoObserve, CascadeDispose or ComponentDependency.

If the element annotated is a method then the method must comply with the additional constraints:

If the element annotated is a field then the field must comply with the additional constraints:

If validateTypeAtRuntime() is set to true then the declared type of the field or method must be annotated with ArezComponentLike. In this mode, type compatibility is validated at runtime rather than compile time while still treating the declared type as component-like for validation only.

This annotation is only supported on elements contained within a type annotated by ArezComponent or ArezComponentLike. Other usages will fail compilation.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Return true and the value of the annotated field or method will be validated at runtime rather than compile time.
  • Element Details

    • validateTypeAtRuntime

      Return true and the value of the annotated field or method will be validated at runtime rather than compile time. This is useful when the declared type is annotated with ArezComponentLike but the runtime value is known to implement ComponentObservable.
      Returns:
      true to defer validation of types until runtime.
      Default:
      false