Class View<S>

Object
kalix.javasdk.view.View<S>
Type Parameters:
S - The type of the state for this view.

public abstract class View<S> extends Object
  • Constructor Details

    • View

      public View()
  • Method Details

    • updateContext

      protected final UpdateContext updateContext()
      Additional context and metadata for an update handler.

      It will throw an exception if accessed from constructor.

    • _internalSetUpdateContext

      public void _internalSetUpdateContext(Optional<UpdateContext> context)
      INTERNAL API
    • _internalSetViewState

      public void _internalSetViewState(S state)
      INTERNAL API
    • viewState

      @ApiMayChange protected final S viewState()
      Returns the view state (row) for this invocation as currently stored in Kalix.

      Note that modifying the state directly will not update it in storage. To save the state, one must call {effects().updateState()}.

      This method can only be called when handling a command. Calling it outside a method (eg: in the constructor) will raise a IllegalStateException exception.

      Throws:
      IllegalStateException - if accessed outside a handler method
    • effects

      protected final View.UpdateEffect.Builder<S> effects()
    • emptyState

      public S emptyState()
      The default implementation of this method returns null. It can be overridden to return a more sensible initial state.
      Returns:
      an empty state object or `null` to hand to the process method when an event for a previously unknown subject id is seen.