update

open override fun update(updateAction: (TEntity) -> TEntity, maxRetries: Int): TEntity?

Reads the current state of the entity, applies a change to it and stores the result. Applies optimistic concurrency using automatic retries.

Return

The entity as returned by the server, possibly with additional fields set. null if the server does not respond with a result entity.

Parameters

updateAction

A callback that takes the current state of the entity and returns it with the desired modifications applied.

maxRetries

The maximum number of retries to perform for optimistic concurrency before giving up.

Throws

The number of retries performed for optimistic concurrency exceeded maxRetries.

when the server responds with HttpStatusCode.BadRequest.

when the server responds with HttpStatusCode.Forbidden.

for other non-success status codes.