Skip to content

Instantly share code, notes, and snippets.

@bhavesh3005sharma
Last active August 24, 2022 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhavesh3005sharma/f167789cc29973d30ce9c2e216939ef2 to your computer and use it in GitHub Desktop.
Save bhavesh3005sharma/f167789cc29973d30ce9c2e216939ef2 to your computer and use it in GitHub Desktop.
@AndroidEntryPoint
class SampleFragment : Fragment() {
// No need to extract it here
// private val expId by lazy { intent?.getStringExtra("EXPERIMENT_ID") }
val viewModel: SampleViewModel by activityViewModels()
.....
.....
}
@HiltViewModel
class SampleViewModel @Inject constructor(
savedStateHandle: SavedStateHandle,
var sampleRepository: SampleRepository,
) : ViewModel() {
val expId by lazy {
savedStateHandle.get<String>("EXPERIMENT_ID")
}
....
....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment