Noha Samir’s Post

View profile for Noha Samir, graphic

Senior Android Engineer @Vama | Ex-YAW AI | Ex-VOIS | Ex-SWVL | Ex- Savics | Google Associate Android Developer Certification

What does "#atomically" mean in the context of the update function for #MutableStateFlow<T>? - #Atomically means performing an operation as a single, indivisible step that is thread-safe and consistent. The update function ensures that the state is updated in a way that prevents race conditions and partial updates, using a loop and compareAndSet to handle concurrent modifications safely. ------- When should I use  _viewState.value = _viewState.value.copy(x = true)  vs  _viewState.update { state -> state.copy(x = true) }? - Use direct assignment in #single-threaded scenarios for simplicity and performance. - Use the update method in #multi-threaded scenarios to ensure atomic, consistent updates. Follow these hashtags to see more content like this! #android #android_interview_questions #android_tips_and_tricks

  • No alternative text description for this image
Mahmoud H. Alim

Senior Software Engineer - Android | Kotlin | Jetpack Compose | KMP | Organizer at Google Developers Group & Android Worldwid

6mo

MVI cries in the corner 😅

Tuan Le

🇸🇪 🇻🇳 Senior Android developer | Secure Coding | Open for challenge

6mo

I suggest change _viewState to _viewStateFlow if this is not collected State from StateFlow.

See more comments

To view or add a comment, sign in

Explore topics