https://kotlinlang.org logo
#compose
Title
# compose
s

shikasd

01/13/2020, 6:28 PM
Hey, I was experimenting with Transition API and noticed that there's no way to check if user specified a key in transition definition or specify defaults. Do you plan to add support for it later? Example:
Copy code
val X = FloatPropKey()
val Y = FloatPropKey()

val def = transitionDefinition {
    state(Initial) {
        this[X] = 0f
    }
}

Transition(definition = def, initState = Initial) { state ->
    val xValue = state[X]
    val yValue = state[Y] // <-- Crashes, as no value specified
}
z

Zsolt

01/13/2020, 6:43 PM
I'd be interested in this too. Use-case: transition with default values that offers client-code to customise them. Client code cannot override already set values, as that will trigger IllegalArgumentException saying that the propKey was already set. But if we let the client code define these values in the first place, now we cannot check what keys weren't set so that we can provide defaults.
2