Skip to content

Instantly share code, notes, and snippets.

@egek92
Created July 10, 2019 10:01
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 egek92/f3654df571cba65b9fd2a39e59dd45ed to your computer and use it in GitHub Desktop.
Save egek92/f3654df571cba65b9fd2a39e59dd45ed to your computer and use it in GitHub Desktop.
// 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