Annotation Interface Subscribe.ValueEntity

Enclosing class:
Subscribe

@Target({TYPE,METHOD}) @Retention(RUNTIME) @Documented public static @interface Subscribe.ValueEntity
Annotation for subscribing to updates from a Value Entity. It can be used both at type and method levels. When used at type level, it means the `View` or `Action` will not be transforming state. When used at method level, it gives the ability to transform the updates into a different state.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Class<? extends kalix.javasdk.valueentity.ValueEntity<?>>
    Assign the class type of the entity one intends to subscribe to, which must extend ValueEntity.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    When true at type level of the `View` the subscription will automatically delete the view state based on ValueEntity deletion fact.
  • Element Details

    • value

      Class<? extends kalix.javasdk.valueentity.ValueEntity<?>> value
      Assign the class type of the entity one intends to subscribe to, which must extend ValueEntity.
    • handleDeletes

      boolean handleDeletes
      When true at type level of the `View` the subscription will automatically delete the view state based on ValueEntity deletion fact. When true at method level it allows to create a special handler for deletes (must be declared to receive zero parameters):
      {@code
       @Subscribe.ValueEntity(MyValueEntity.class)
       public UpdateEffect<MyView> onChange(ValueEntity valueEntity) {
         return effects().updateState(...);
       }
      
       @Subscribe.ValueEntity(value = MyValueEntity.class, handleDeletes = true)
       public UpdateEffect<MyView> onDelete() {
         return effects().deleteState();
       }
       </pre>
      
       The flag has no effect when used at type level of the `Action`. On the `Action` method level it allows to create a delete handler,
       similar to the example above.
      Default:
      false