Annotation Interface OnDepsChange


Identifies method that will be invoked when the dependencies of the paired Observe annotated method are changed.

The method that is annotated with this annotation must comply with the additional constraints:

  • Must not be annotated with any other arez annotation
  • Must not be private
  • Must not be static
  • Must not be abstract
  • Must have either no parameters or a single parameter of type Observer
  • Must not return a value
  • Must not throw an exception
  • Must be accessible to the class annotated by the ArezComponent annotation.
  • Should not be public as not expected to be invoked outside the component. A warning will be generated but can be suppressed by the SuppressWarnings or SuppressArezWarnings annotations with a key "Arez:PublicHookMethod". This warning is also suppressed by the annotation processor if it is implementing an interface method.
  • Should not be protected if in the class annotated with the ArezComponent annotation as the method is not expected to be invoked outside the component. A warning will be generated but can be suppressed by the SuppressWarnings or SuppressArezWarnings annotations with a key "Arez:ProtectedMethod".

If the annotated method has a parameter of type Observer then the underlying Observer instance associated with the Observe/OnDepsChange annotated method is passed to the method when dependencies change. This is extremely useful when implementing asynchronous callbacks.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Return the name of the paired Tracked relative to the component.
  • Element Details

    • name

      @Nonnull String name
      Return the name of the paired Tracked relative to the component. The value must conform to the requirements of a java identifier. The name need not be specified. If the Observe annotated method is named "render" then this will default to being named "onRenderDepsChange".
      Returns:
      the name of the paired Observe annotated method relative to the component.
      Default:
      "<default>"