getAndUpdate

fun <T> StateContainer<T>.getAndUpdate(updater: (T) -> T): T?

Updates the state and returns the previous state if successful, or null if failed.