All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.fuel.Fuel.kt Maven / Gradle / Ivy

There is a newer version: 3.0.0-alpha04
Show newest version
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