Skip to content

Instantly share code, notes, and snippets.

@seyedjafariy
Created May 6, 2019 23:46
Show Gist options
  • Save seyedjafariy/5404eefa9a5cc10312e0740dd4a2b1e7 to your computer and use it in GitHub Desktop.
Save seyedjafariy/5404eefa9a5cc10312e0740dd4a2b1e7 to your computer and use it in GitHub Desktop.
extensions file to ease the usages of Dagger dependencies
fun Context.coreComponent(): CoreComponent =
if (applicationContext is CoreComponentProvider) {
(applicationContext as CoreComponentProvider).core()
} else {
throw IllegalArgumentException("app class must implement CoreComponentProvider")
}
fun View.coreComponent(): CoreComponent =
context.coreComponent()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment