--

You would use `.value` if you wanted to entirely overwrite the previous state. `.update` is used when you have concerns about multiple thread access and atomic updates.

Having said that, you can safely always use `.update`. There's a very slight performance loss with the `compareAndSet` function being called every time so it's up to you if you feel that's worth it.

--

--

Michael Ferguson
Michael Ferguson

Written by Michael Ferguson

Android software developer. Views and opinions expressed are my own and not that of my employer.

No responses yet