Interface LiveCounter

All Superinterfaces:
LiveCounterChange, ObjectLifecycleChange

public interface LiveCounter extends LiveCounterChange, ObjectLifecycleChange
The LiveCounter interface provides methods to interact with a live counter. It allows incrementing, decrementing, and retrieving the current value of the counter, both synchronously and asynchronously.
  • Method Details

    • increment

      @Blocking void increment(@NotNull @NotNull Number amount)
      Increments the value of the counter by the specified amount. Send a COUNTER_INC operation to the realtime system to increment a value on this LiveCounter object. This does not modify the underlying data of this LiveCounter object. Instead, the change will be applied when the published COUNTER_INC operation is echoed back to the client and applied to the object following the regular operation application procedure. Spec: RTLC12
      Parameters:
      amount - the amount by which to increment the counter
    • decrement

      @Blocking void decrement(@NotNull @NotNull Number amount)
      Decrements the value of the counter by the specified amount. An alias for calling increment(Number) with a negative amount. Spec: RTLC13
      Parameters:
      amount - the amount by which to decrement the counter
    • incrementAsync

      @NonBlocking void incrementAsync(@NotNull @NotNull Number amount, @NotNull @NotNull ObjectsCallback<Void> callback)
      Increments the value of the counter by the specified amount asynchronously. Send a COUNTER_INC operation to the realtime system to increment a value on this LiveCounter object. This does not modify the underlying data of this LiveCounter object. Instead, the change will be applied when the published COUNTER_INC operation is echoed back to the client and applied to the object following the regular operation application procedure. Spec: RTLC12
      Parameters:
      amount - the amount by which to increment the counter
      callback - the callback to be invoked upon completion of the operation.
    • decrementAsync

      @NonBlocking void decrementAsync(@NotNull @NotNull Number amount, @NotNull @NotNull ObjectsCallback<Void> callback)
      Decrements the value of the counter by the specified amount asynchronously. An alias for calling incrementAsync(Number, ObjectsCallback) with a negative amount. Spec: RTLC13
      Parameters:
      amount - the amount by which to decrement the counter
      callback - the callback to be invoked upon completion of the operation.
    • value

      @NotNull @Contract(pure=true) @NotNull Double value()
      Retrieves the current value of the counter.
      Returns:
      the current value of the counter as a Double.