Answer the question
In order to leave comments, you need to log in
Do I need to do DI for simple Kotlin objects?
There is an Rx method inside which I do some transformation of the response from the server using kotlin
object - RawMediaPreviewResponseConverter .
...
.subscribe({
val mediaPreviewResponse = RawMediaPreviewResponseConverter.getMediaPreviewResponse(it)
_downloadedMediaPreviewsResponse.postValue(mediaPreviewResponse)
_networkState.postValue(NetworkState.LOADED)
}
...
Answer the question
In order to leave comments, you need to log in
In general, yes, everything needs to be implemented. Let's give an example. Here you have some kind of media preview converter. I don't know what he does, but let's say he formats some kind of preview, photo or video, right? In this case, you may need to use the context to get the screen sizes, because the preview on different screens may have different sizes. This is where di comes in handy.
Well, if your converter has no dependencies, it is not open and not an interface, then you can also use object, there is no difference at all.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question