commonMain.fuel.Fuel.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fuel Show documentation
Show all versions of fuel Show documentation
The easiest HTTP networking library for Kotlin/Android
package fuel
public object Fuel {
private var httpLoader: HttpLoader? = null
private var httpLoaderFactory: HttpLoaderFactory? = null
public fun loader(): HttpLoader = httpLoader ?: newHttpLoader()
public fun setHttpLoader(loader: HttpLoader) {
httpLoaderFactory = null
httpLoader = loader
}
public fun setHttpLoader(factory: HttpLoaderFactory) {
httpLoaderFactory = factory
httpLoader = null
}
private fun newHttpLoader(): HttpLoader {
// Check again in case httpLoader was just set.
httpLoader?.let { return it }
// Create a new HttpLoader.
val loader = httpLoaderFactory?.newHttpLoader() ?: FuelBuilder().build()
httpLoaderFactory = null
httpLoader = loader
return loader
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy