Skip to content

Instantly share code, notes, and snippets.

@egek92 egek92/ScopeKoin.kt
Created Jul 10, 2019

Embed
What would you like to do?
// define scope in your module
module {
scope("scope_id") { Presenter() }
}
// use scope in your activity
class SomeActivity: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// ... other required stuff
// create the scope
val session = getKoin().createScope("scope_id")
// or get scope if already created before
val session = getKoin().getScope("scope_id")
// will return the same instance of
// Presenter until Scope 'scope_id' is closed
val presenter = get<Presenter>()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.