I inject viewModels,repositories,fragments,Utils and ... but Is it good way to inject common class with dependency injection Koin or Dagger-hilt?
Suppose that we want to use StringBuilder() class in fragment
First approach :
We can inject it
val otherModule= module {
single { StringBuilder() }
}
And use it in fragment like this :
class Fragment : BaseFragment(){
private val mPassword : StringBuilder by inject()
}
Second approach :
We can create new instance without injection
class Fragment : BaseFragment(){
private var mPassword = StringBuilder()
}
My question is the first approach is common way for us ?