withOptimisticUpdate

inline suspend fun <T : Any, R> withOptimisticUpdate(    update: OptimisticUpdate<T>,     replica: PhysicalReplica<T>,     noinline onSuccess: suspend () -> Unit? = null,     noinline onError: suspend (Exception) -> Unit? = null,     noinline onCanceled: suspend () -> Unit? = null,     noinline onFinished: suspend () -> Unit? = null,     block: () -> R): R

Executes an optimistic update on a replica. update is applied immediately on observed replica state. Then block is executed. If block succeed an update is committed, otherwise an update is rolled back.

onSuccess, onError, onCanceled, onFinished are optional callbacks for additional actions.