⚡
Coroutine Deep Cuts
Find the bugs in each code snippet
←→NavigateAShow remainingRReset
🎯Bug Formula: What's wrong → What breaks for the user → The fix → The trade-off
Find the bugs in each code snippet
1class DashboardViewModel(2 private val hotelRepo: HotelRepository,3 private val bookingRepo: BookingRepository,4 private val reviewRepo: ReviewRepository5) : ViewModel() {67 val uiState = MutableStateFlow(DashboardState())89 fun loadDashboard() {10 viewModelScope.launch(SupervisorJob()) {11 val hotels = async { hotelRepo.getFeatured() }12 val bookings = async { bookingRepo.getUpcoming() }13 val reviews = async { reviewRepo.getRecent() }1415 uiState.update {16 it.copy(17 hotels = hotels.await(),18 bookings = bookings.await(),19 reviews = reviews.await(),20 isLoading = false21 )22 }23 }24 }25}Find the bugs in each code snippet
1class DashboardViewModel(2 private val hotelRepo: HotelRepository,3 private val bookingRepo: BookingRepository,4 private val reviewRepo: ReviewRepository5) : ViewModel() {67 val uiState = MutableStateFlow(DashboardState())89 fun loadDashboard() {10 viewModelScope.launch(SupervisorJob()) {11 val hotels = async { hotelRepo.getFeatured() }12 val bookings = async { bookingRepo.getUpcoming() }13 val reviews = async { reviewRepo.getRecent() }1415 uiState.update {16 it.copy(17 hotels = hotels.await(),18 bookings = bookings.await(),19 reviews = reviews.await(),20 isLoading = false21 )22 }23 }24 }25}