spxbhuhb / adaptive

Consolidated full-stack application development library for Kotlin
Apache License 2.0
0 stars 0 forks source link

Make state handling easier for manual implementation #27

Open toth-istvan-zoltan opened 2 weeks ago

toth-istvan-zoltan commented 2 weeks ago

Right now the state handling in manual fragments is a bit cumbersome because the indices are managed manually.

With compiler plugin support the following pattern should be implemented:

@AdaptiveActual
class SomeFragment(
    adapter: AdaptiveAdapter,
    parent: AdaptiveFragment,
    index: Int
) : AdaptiveFragment(adapter, parent, index, auto, auto) {

    val name : String? by state()

    val otherName by state<String?>()

    override fun genPatchInternal() : Boolean {
        if (name.isDirty()) {
            /* ... */
        }
    }
}