Skip to content

Latest commit

 

History

History
44 lines (29 loc) · 1.01 KB

File metadata and controls

44 lines (29 loc) · 1.01 KB

Description

Application that displays current wifi status on screen when user toggles wifi connection on their phone

To ensure status updates are immediate do either of the following

Option 1 - Call method in init block of viewmodel and collect it in UI
// In your VM
    init {
        checkWifiConnectionStatus()
    }

// In your UI
 val viewModel: WifiConnectionStatusViewModel = hiltViewModel()
 val state by viewModel.isWifiConnected.collectAsState()

 WifiConnectionStatusScreen(state)
Option 2 - Only call method in launched effect in UI
 val viewModel: WifiConnectionStatusViewModel = hiltViewModel()
 val state by viewModel.isWifiConnected.collectAsState()

  LaunchedEffect(Unit) {
    viewModel.checkWifiConnectionStatus()
}

Dev Proof

Wifi.Status.Proof.mov