Package io.ably.lib.objects.type.counter
Interface LiveCounter
- All Superinterfaces:
-
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.ably.lib.objects.type.counter.LiveCounterChange
LiveCounterChange.Listener
Nested classes/interfaces inherited from interface io.ably.lib.objects.type.ObjectLifecycleChange
ObjectLifecycleChange.Listener
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Decrements the value of the counter by the specified amount.void
decrementAsync
(@NotNull Number amount, @NotNull ObjectsCallback<Void> callback) Decrements the value of the counter by the specified amount asynchronously.void
Increments the value of the counter by the specified amount.void
incrementAsync
(@NotNull Number amount, @NotNull ObjectsCallback<Void> callback) Increments the value of the counter by the specified amount asynchronously.@NotNull Double
value()
Retrieves the current value of the counter.Methods inherited from interface io.ably.lib.objects.type.counter.LiveCounterChange
subscribe, unsubscribe, unsubscribeAll
Methods inherited from interface io.ably.lib.objects.type.ObjectLifecycleChange
off, offAll, on
-
Method Details
-
increment
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
Decrements the value of the counter by the specified amount. An alias for callingincrement(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 callingincrementAsync(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
Retrieves the current value of the counter.- Returns:
- the current value of the counter as a Double.
-