soil
1.0.0-alpha15indexedSimplifies Compose development with features for seamless data fetching, extensible validation, and flexible state management. Enhances readability and minimizes re-composition impact.
Simplifies Compose development with features for seamless data fetching, extensible validation, and flexible state management. Enhances readability and minimizes re-composition impact.
Simplify Compose, Accelerate Development :rocket:
The following example demonstrates the basic usage of a Query to fetch the number of GitHub stars for the Soil GitHub project itself.
The Soil library for Kotlin Multiplatform now includes experimental support for Kotlin Wasm. If your browser supports WasmGC, you can run the sample app directly in the browser.
:point_right: Sample App
Source code: https://github.com/soil-kt/soil/tree/main/sample/
Soil is available on mavenCentral().
Supported targets:
Please visit docs.soil-kt.com for Quick Start, guides of features and more.
Thank you for featuring our library in the following sources:
Copyright 2024 Soil Contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance the License.
You may obtain a copy of the License at
https:
Unless applicable law agreed to writing, software
distributed under the License distributed an BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
See the License the specific language governing permissions
limitations under the License.
private val swrClient = SwrCache(
policy = SwrCachePolicy(coroutineScope = SwrCacheScope()) {
httpClient = /* createKtorHttpClient() */
}
)
@Composable
fun App() {
SwrClientProvider(client = swrClient) {
Box {
when (val query = rememberQuery(key = HelloQueryKey())) {
is QuerySuccessObject -> Text("✨ ${query.data.stargazersCount}")
is QueryLoadingObject -> Text("Loading...")
is QueryLoadingErrorObject,
is QueryRefreshErrorObject -> Text("Error :(")
}
}
}
}
@Immutable
class HelloQueryKey : KeyEquals(), QueryKey<Repo> by buildKtorQueryKey(
id = QueryId("demo/hello-query"),
fetch = { // HttpClient.() -> Repo
get("https://api.github.com/repos/soil-kt/soil").body()
}
)
@Serializable
data class Repo(
@SerialName("stargazers_count")
val stargazersCount: Int
)
dependencies {
val soil = "1.0.0-alpha15"
// Query
implementation("com.soil-kt.soil:query-core:$soil")
// Query for Compose
implementation("com.soil-kt.soil:query-compose:$soil")
// optional - receivers for Ktor (3.x)
implementation("com.soil-kt.soil:query-receivers-ktor:$soil")
// optional - Test helpers
testImplementation("com.soil-kt.soil:query-test:$soil")
// Form
implementation("com.soil-kt.soil:form:$soil")
// Space
implementation("com.soil-kt.soil:space:$soil")
// Experimental
implementation("com.soil-kt.soil:lazyload:$soil")
implementation("com.soil-kt.soil:optimistic-update:$soil")
implementation("com.soil-kt.soil:reacty:$soil")
}
Surfaced from shared tags and platforms — no rankings paid for.