is there a better way to do this? ```chipGroup.lis...
# arrow
c
is there a better way to do this?
Copy code
chipGroup.list transform {
    it.map { chip ->
        when (chip) {
            is FilterChip.All -> chip.copy(selected = filterChip == chip)
            is FilterChip.Finance -> chip.copy(selected = filterChip == chip)
            is FilterChip.Investment -> chip.copy(selected = filterChip == chip)
            is FilterChip.Saving -> chip.copy(selected = filterChip == chip)
            is FilterChip.Other -> chip.copy(selected = filterChip == chip)
        }
    }
}

@optics
data class ChipGroup(
    val list: List<FilterChip>,
    val onChange: (FilterChip) -> Unit,
) {
    companion object
}

@optics
sealed interface FilterChip {
    val title: String
    val selected: Boolean

...
}
a
not as of now, we haven't implemented yet lifting properties from the parent class of a sealed hierachy as lenses...
KopyKat does have that feature https://kopyk.at/#copy-for-sealed-hierarchies
c
👍
s
Ah, have we still not added that 😅 I thought we already did at some point, the issue has been open for years 😕