Skip to content

Increment by N, return current

Atomically adds the given value to the current value and returns the updated (current) value of the counter. Multiple concurrent client requests are guaranteed to return updated value.

Future<int> Backendless.counters.addAndGet(String counterName, int value);

IAtomic counter = Backendless.counters.of(String counterName);
Future<int> counter.addAndGet(int value);

where:

Argument                Description
counterName name of the counter to update.

Example

Function callback = (counterValue) => print("current counter value is - $counterValue");

Backendless.counters.addAndGet("my counter", 1000).then(callback);

IAtomic myCounter = Backendless.counters.of("my counter");
myCounter.addAndGet(2000).then(callback);