Skip to content

Commit

Permalink
Minor improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
philips77 committed Oct 25, 2022
1 parent 1c06653 commit b0620de
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.onEach
import no.nordicsemi.android.common.navigation.Navigator
import no.nordicsemi.android.common.test.R
Expand Down Expand Up @@ -58,7 +58,7 @@ class BasicPageViewModel @Inject constructor(
init {
navigator.resultFrom(Scanner)
// Filter out results of cancelled navigation.
.filter { it != null }
.mapNotNull { it }
// Save the result in SavedStateHandle.
.onEach { savedStateHandle[DEVICE_KEY] = it }
// And finally, launch the flow in the ViewModelScope.
Expand Down

0 comments on commit b0620de

Please sign in to comment.