spxbhuhb / adaptive

Consolidated full-stack application development library for Kotlin
https://adaptive.fun
Apache License 2.0
3 stars 0 forks source link

Clean up state variable bindings #39

Open toth-istvan-zoltan opened 4 months ago

toth-istvan-zoltan commented 4 months ago

AdaptiveStateVariableBinding is used by producers and state accessor functions. There is a bit of confusion what a binding exactly means and what is it supposed to exactly do.

I've removed the fromBinding parameter from AdaptivePropertyProvider.setValue during adat class development, so now setValue calls the binding that called setValue as well.

    override fun setValue(path: Array<String>, value: Any?, fromBinding: AdaptiveStateVariableBinding<*>) {
        when {
            path[0] == "i" -> values[0] = value
        }
        bindings.forEach { if (it != fromBinding && it.path.contentEquals(path)) it.setValue(path, false) }
    }

I have to decide the pattern/convention for state accessors:

That means I don't really need AdaptiveStateVariableBinding.setValue as the change goes through the store anyways. More precisely, I don't have to set the value directly.

The only question is if I want to keep the possibility to directly write back to the state variable. I'm not sure about that.

toth-istvan-zoltan commented 4 months ago

Also, don't forget: adaptive-kotlin-plugin/testData/box/foundation/call/propertyAccessBinding.kt

toth-istvan-zoltan commented 4 months ago

Fixed some binding related bugs and added some documentation: Bindings