
Enhances bean fields with mutable state capabilities, allowing direct use as `MutableState<T>`. Automatically converts non-constructor attributes and supports serialization customization and Compose variability annotations.
Add status to beans in Compose Multiplatform, Fields in beans can be directly used as the MutableState<T>
Step 1 and 2.add dependencies:
plugins {
...
id("com.google.devtools.ksp") version "2.1.21-2.0.1"//this,The left 2.1.21 corresponds to your the Kotlin version,more version: https://github.com/google/ksp/releases
}
dependencies {
...
implementation("io.github.ltttttttttttt:Buff-lib:$version")//this,such as 2.0.2
ksp("io.github.ltttttttttttt:Buff:$version")//this,such as 2.0.2
}plugins {
...
id("com.google.devtools.ksp") version "2.1.21-2.0.1"
}
...
val commonMain by getting {
dependencies {
...
api("io.github.ltttttttttttt:Buff-lib:$version")//this,such as 2.0.2
}
}
...
dependencies {
add("kspCommonMainMetadata", "io.github.ltttttttttttt:Buff:$version")
}Step 3.Use Buff
Add the @Buff to your bean, call the addBuff() transform to the new Any, The attribute (such as name) will be automatically converted to MutableState<T>
@Buff
class BuffBean(
val id: Int? = null,
) {
var isSelect: Boolean = false
}Example(reference UseBuff.kt):
val buffBean = BuffBean(0)
val bean = buffBean.addBuff()//Transform to the BuffBeanWithBuff
bean.isSelect = true//The isSelect's getter and setter have the effect of MutableState<T>
bean.removeBuff()//Fallback to BuffBean(optional)Step 4.If you are using a version of ksp less than 1.0.9, the following configuration is required:
Step 5.Optional configuration
@Buff(
scope,//which attributes of the bean should be buffed
variability//What mutable properties to deal with
)Add custom code, reference [KspOptions.handlerCustomCode], Your app dir, build.gradle.kts add:
ksp {
arg("customInClassWithBuff", "//Class end")//in class
arg("customInFileWithBuff", "//File end")//in file
}The project provides support for Compose variability annotations. If the original bean has @Stable or @Immutable annotations, the generated Buff class also has corresponding annotations
Add status to beans in Compose Multiplatform, Fields in beans can be directly used as the MutableState<T>
Step 1 and 2.add dependencies:
plugins {
...
id("com.google.devtools.ksp") version "2.1.21-2.0.1"//this,The left 2.1.21 corresponds to your the Kotlin version,more version: https://github.com/google/ksp/releases
}
dependencies {
...
implementation("io.github.ltttttttttttt:Buff-lib:$version")//this,such as 2.0.2
ksp("io.github.ltttttttttttt:Buff:$version")//this,such as 2.0.2
}plugins {
...
id("com.google.devtools.ksp") version "2.1.21-2.0.1"
}
...
val commonMain by getting {
dependencies {
...
api("io.github.ltttttttttttt:Buff-lib:$version")//this,such as 2.0.2
}
}
...
dependencies {
add("kspCommonMainMetadata", "io.github.ltttttttttttt:Buff:$version")
}Step 3.Use Buff
Add the @Buff to your bean, call the addBuff() transform to the new Any, The attribute (such as name) will be automatically converted to MutableState<T>
@Buff
class BuffBean(
val id: Int? = null,
) {
var isSelect: Boolean = false
}Example(reference UseBuff.kt):
val buffBean = BuffBean(0)
val bean = buffBean.addBuff()//Transform to the BuffBeanWithBuff
bean.isSelect = true//The isSelect's getter and setter have the effect of MutableState<T>
bean.removeBuff()//Fallback to BuffBean(optional)Step 4.If you are using a version of ksp less than 1.0.9, the following configuration is required:
Step 5.Optional configuration
@Buff(
scope,//which attributes of the bean should be buffed
variability//What mutable properties to deal with
)Add custom code, reference [KspOptions.handlerCustomCode], Your app dir, build.gradle.kts add:
ksp {
arg("customInClassWithBuff", "//Class end")//in class
arg("customInFileWithBuff", "//File end")//in file
}The project provides support for Compose variability annotations. If the original bean has @Stable or @Immutable annotations, the generated Buff class also has corresponding annotations