Package 

Interface LiveCounter

  • All Implemented Interfaces:
    io.ably.lib.objects.type.ObjectLifecycleChange , io.ably.lib.objects.type.counter.LiveCounterChange

    
    public interface LiveCounter
     implements 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 Summary

      Modifier and Type Method Description
      abstract void increment(@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.
      abstract void decrement(@NotNull() Number amount) Decrements the value of the counter by the specified amount.
      abstract void incrementAsync(@NotNull() Number amount, @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.
      abstract void decrementAsync(@NotNull() Number amount, @NotNull() ObjectsCallback<Void> callback) Decrements the value of the counter by the specified amount asynchronously.
      abstract Double value() Retrieves the current value of the counter.
      • Methods inherited from class io.ably.lib.objects.type.counter.LiveCounterChange

        subscribe, unsubscribe, unsubscribeAll
      • Methods inherited from class io.ably.lib.objects.type.ObjectLifecycleChange

        off, offAll, on
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • increment

        @Blocking() abstract void increment(@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 whenthe published COUNTER_INC operation is echoed back to the client and applied to the object following the regularoperation application procedure.Spec: RTLC12

        Parameters:
        amount - the amount by which to increment the counter
      • decrement

        @Blocking() abstract void decrement(@NotNull() Number amount)

        Decrements the value of the counter by the specified amount.An alias for calling increment with a negative amount.Spec: RTLC13

        Parameters:
        amount - the amount by which to decrement the counter
      • incrementAsync

        @NonBlocking() abstract void incrementAsync(@NotNull() Number amount, @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 whenthe published COUNTER_INC operation is echoed back to the client and applied to the object following the regularoperation 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() abstract void decrementAsync(@NotNull() Number amount, @NotNull() ObjectsCallback<Void> callback)

        Decrements the value of the counter by the specified amount asynchronously.An alias for calling incrementAsync 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) abstract Double value()

        Retrieves the current value of the counter.