Running into a strange issue when I'm trying to fo...
# compose-desktop
m
Running into a strange issue when I'm trying to force recompositions, here's my code with comments explaining the issue: (video in thread)
Copy code
@Composable
fun TreeScope.TypeBranch(node: TreeNode, def: FBType<Any>, skipRef: Boolean) {
    val counter by remember { node.updateCounter }  // This is updated whenever a node's value's property is changed
    val node = remember(counter) { node }           // Trigger recomposition when counter updates, even if `node.value` is the same object

    if (ReferenceRegistry.isReferenceType(node.type) && !skipRef) {
        // Not relevant in my issue, removed for brevity
    } else {
        if (node is ReferenceNode) {
            // Not relevant in my issue, removed for brevity
        } else {
            // FIXME: For some reason, the updated property stays the same until I hide and un-hide it in this BranchView
            // This could be fixed by manually forcing a hide/un-hide with a sideeffect of some kind, but it harms the user experience a LOT
            BranchView(node, name = node.displayText()) {
                for (prop in def.props) {
                    // Renders the property
                    Branch(PropertyNode(node, prop as FBProp<Any, Any?>))
                }
            }
        }
    }
}

@Composable
private fun TreeScope.Leaf(node: TreeNode) {
    // Called by Branch calls for primitives and strings
    val counter by remember { node.updateCounter }  // Update counter
    val node = remember(counter) { node }           // Force recomposition
    val value by node.value

    // This doesn't seem to update for some reason
    val valueString = when (value) {
        is String -> "\"$value\""
        is ByteArray -> "byte[${(value as ByteArray).size}]"
        is Array<*> -> "(empty)"
        else -> value.toString()
    }

    LeafView(node, name = "${node.displayText()} = $valueString")
}
A video showcasing the problem:
z
Lots of suspicious remembers in there, but if i had to guess i'd guess the problem has something to do with using loops without
key {}