Interface LiveCounterPathObject
- All Superinterfaces:
PathObject
PathObject whose underlying value is expected to be a LiveCounter.
Provides type-safe access to counter operations such as value(),
increment(Number) and decrement(Number).
Counters are terminal nodes - navigation via at(...) is not available
here because it is only defined on LiveMapPathObject.
Operations are best-effort and resolve the path at call time. Read operations
return null when the path does not resolve to a LiveCounter; write
operations complete the returned CompletableFuture exceptionally with an
AblyException (status 400, code 92007) in that case.
Spec: RTTS6b
-
Method Summary
Modifier and TypeMethodDescription@NotNull CompletableFuture<Void>Decrements theLiveCounterat this path by1.@NotNull CompletableFuture<Void>Decrements theLiveCounterat this path byamount.@NotNull CompletableFuture<Void>Increments theLiveCounterat this path by1.@NotNull CompletableFuture<Void>Increments theLiveCounterat this path byamount.@Nullable Doublevalue()Returns the current value of theLiveCounterat this path, ornullwhen the path does not resolve to aLiveCounter.Methods inherited from interface io.ably.lib.liveobjects.path.PathObject
asBinary, asBoolean, asJsonArray, asJsonObject, asLiveCounter, asLiveMap, asNumber, asString, compactJson, exists, getType, instance, path, subscribe, subscribe
-
Method Details
-
value
Returns the current value of theLiveCounterat this path, ornullwhen the path does not resolve to aLiveCounter.Spec: RTPO7 / RTLC5
- Returns:
- the counter value, or
null
-
increment
Increments theLiveCounterat this path by1. Equivalent to callingincrement(Number)with1.Spec: RTPO17a1 (default
amountof1)- Returns:
- a future that completes when the operation has been acknowledged
-
increment
Increments theLiveCounterat this path byamount.Sends a
COUNTER_INCoperation to the realtime system; the local state is updated when the operation is echoed back. The returned future completes exceptionally with anAblyException(status 400, code 92005) if the path cannot be resolved, or (status 400, code 92007) if the resolved value is not aLiveCounter.Spec: RTPO17
- Parameters:
-
amount- the amount to add (may be negative) - Returns:
- a future that completes when the operation has been acknowledged
-
decrement
Decrements theLiveCounterat this path by1. Equivalent to callingdecrement(Number)with1.Spec: RTPO18a1 (default
amountof1)- Returns:
- a future that completes when the operation has been acknowledged
-
decrement
Decrements theLiveCounterat this path byamount. Equivalent to callingincrement(Number)with a negated value.Spec: RTPO18
- Parameters:
-
amount- the amount to subtract (may be negative) - Returns:
- a future that completes when the operation has been acknowledged
-