Created
September 21, 2020 12:45
-
-
Save nomanr/c86774f874803498724a5f2a4b2e3d3a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.hilt.Assisted | |
import androidx.hilt.lifecycle.ViewModelInject | |
import androidx.lifecycle.LiveData | |
import androidx.lifecycle.SavedStateHandle | |
import androidx.lifecycle.ViewModel | |
class ExampleViewModel @ViewModelInject constructor( | |
private val someUseCase: SomeUseCase, | |
@Assisted private val savedStateHandle: SavedStateHandle | |
) : ViewModel() { | |
//Get plain argument | |
val argumentA: String = savedStateHandle.get<>(KEY_ARGUMENT_A) | |
// Get argument as LiveData | |
val argumentA: LiveData<String> = savedStateHandle.getLiveData(KEY_ARGUMENT_A) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment