Interface MutableState<T>

Type Parameters:
T - the value type
All Superinterfaces:
State<T>, StateToken
All Known Implementing Classes:
InitialStateImpl, MutableStateImpl

public interface MutableState<T> extends State<T>
Mutable per-context state. Writes are main-thread only and mark watching components dirty; dirty tokens flush coalesced at the end of the current engine entry point.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    set(@NotNull ViewContext context, T value)
    Writes this token's value for the given context and marks watchers dirty.
    void
    update(@NotNull ViewContext context, @NotNull UnaryOperator<T> fn)
    Read-modify-write convenience: applies fn to the current value and stores the result.

    Methods inherited from interface tech.guilhermekaua.spigotboot.inventoryapi.state.State

    get
  • Method Details

    • set

      void set(@NotNull @NotNull ViewContext context, @Nullable T value)
      Writes this token's value for the given context and marks watchers dirty.
      Parameters:
      context - an active context of the owning view
      value - the new value, possibly null
      Throws:
      StaleContextException - when the context belongs to another view or is closed
      IllegalStateException - when called off the main thread
    • update

      void update(@NotNull @NotNull ViewContext context, @NotNull @NotNull UnaryOperator<T> fn)
      Read-modify-write convenience: applies fn to the current value and stores the result. Main thread only.
      Parameters:
      context - an active context of the owning view
      fn - the function producing the new value from the current one; invoked exactly once on the current value. Side effects inside fn are safe (unlike SharedState.update(java.util.function.UnaryOperator<T>))
      Throws:
      StaleContextException - when the context belongs to another view or is closed
      IllegalStateException - when called off the main thread