Skip to content

Instantly share code, notes, and snippets.

@arnaudgiuliani
Last active October 13, 2020 11:31
Show Gist options
  • Select an option

  • Save arnaudgiuliani/6715cfd92cbca0e20f6acfb6610cc7c9 to your computer and use it in GitHub Desktop.

Select an option

Save arnaudgiuliani/6715cfd92cbca0e20f6acfb6610cc7c9 to your computer and use it in GitHub Desktop.
// Implementing our own Scope delegation
class MVPActivity : AppCompatActivity(R.layout.mvp_activity), KoinScopeComponent {
// Create scope
override val scope: Scope by lazy { newScope() }
// Inject presenter with org.koin.core.scope.inject extension
// also can use directly the scope: scope.inject<>()
val presenter: ScopedPresenter by inject()
// Don't forget to close it when finish
override fun onDestroy() {
super.onDestroy()
scope.close()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment