withOptimisticUpdate
inline suspend fun <K : Any, T : Any, R> withOptimisticUpdate( update: OptimisticUpdate<T>, replica: KeyedPhysicalReplica<K, T>, key: K, noinline onSuccess: suspend () -> Unit? = null, noinline onError: suspend (Exception) -> Unit? = null, noinline onCanceled: suspend () -> Unit? = null, noinline onFinished: suspend () -> Unit? = null, block: () -> R): R
Content copied to clipboard
Executes an optimistic update on a keyed replica for a given key. 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.