Skip to content

Instantly share code, notes, and snippets.

@kibotu
Created March 6, 2019 12:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kibotu/deb8b1f0c10ceb5d2532317ee57b1616 to your computer and use it in GitHub Desktop.
Save kibotu/deb8b1f0c10ceb5d2532317ee57b1616 to your computer and use it in GitHub Desktop.
koin ui module
val uiModule = module(definition = {
factory { get<NavHostFragment>().navController }
factory { ContextHelper.getAppCompatActivity()!!.supportFragmentManager.findFragmentById(R.id.navHost) as NavHostFragment }
})
inline fun <reified T : Any> Any.inject(
name: String = "",
scope: Scope? = null,
noinline parameters: ParameterDefinition = emptyParameterDefinition()
) = lazy { getKoin().koinContext.get<T>(name, scope, parameters) }
@kibotu
Copy link
Author

kibotu commented Mar 6, 2019

val navHost: NavHostFragment by inject()

@kibotu
Copy link
Author

kibotu commented Mar 6, 2019

val navController: NavController by inject()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment