Increment by 1, return previous¶
Atomically increments by one the current value and returns the previous value of the counter. It is possible that multiple concurrent client requests may receive the same previous value. This occurs since only the incrementing part of the logic is atomic, the retrieval of the value before it is incremented is not.
Future<int> Backendless.counters.getAndIncrement(String counterName); IAtomic counter = Backendless.counters.of(String counterName); Future<int> counter.getAndIncrement();
||name of the counter to increment.|
Function callback = (counterValue) => print("previous counter value is - $counterValue"); Backendless.counters.getAndIncrement("my counter").then(callback); IAtomic myCounter = Backendless.counters.of("my counter"); myCounter.getAndIncrement().then(callback);