coil-kt / coil

Image loading for Android and Compose Multiplatform.
https://coil-kt.github.io/coil/
Apache License 2.0
10.84k stars 665 forks source link

[Coil 3] Use Call.Factory rather than OkHttpClient when creating OkHttpNetworkFetcher #2060

Closed jamesmissen closed 10 months ago

jamesmissen commented 10 months ago

Describe the solution you'd like

It would be nice to allow OkHttpNetworkFetcher to be built using the more generic OkHttp Call.Factory, rather than the concrete OkHttpClient class. Using Call.Factory was previously an option for building ImageLoaders in Coil 2.x.

As a side note, it was also nice to have the lazy/non-lazy options, and also the () -> X rather than Lazy<X> initializer, given that Kotlin's Lazy is not a functional interface (not sure if there are any other considerations though).

Additional context

colinrtwhite commented 10 months ago

Great callout - fixed here. I'll remove Lazy from the public API as well. In the meantime you can create a functional lazy using callFactory = lazy { OkHttpClient() }