Skip to content

Instantly share code, notes, and snippets.

@skywall
Created October 24, 2020 21:16
Show Gist options
  • Save skywall/bc8a465d31b4337861db7fad08b8156f to your computer and use it in GitHub Desktop.
Save skywall/bc8a465d31b4337861db7fad08b8156f to your computer and use it in GitHub Desktop.
BaseFragment in Home module
abstract class BaseFragment : Fragment() {
private object ModuleComponent : SingletonHolder<HomeComponent, Context>({ context ->
DaggerHomeComponent
.factory()
.create(CoreComponentHolder.getInstance(context.applicationContext as App))
})
val homeComponent: HomeComponent
get() = ModuleComponent.getInstance(requireContext())
override fun onAttach(context: Context) {
super.onAttach(context)
inject()
}
abstract fun inject()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment