Thread
#compose
    Shakil Karim

    Shakil Karim

    1 year ago
    Is the Type still consider Immutable/Stable for Compose? if the class is something like this 🧵
    @Immutable data class SomeClass( val someString: Char? = null val map: Map<String,Any?>?= null )
    Nathan Castlehow

    Nathan Castlehow

    1 year ago
    I would say no? “Any?” could be assigned a value which is mutable? Open to others suggestions.
    val immutableMap:Map<String,Any?>? = mapOf(Pair("test", mutableListOf(1)))
     (immutableMap!!["test"] as MutableList<Int>).add(2)
    Above is my thinking why its not immutable. Compose would not be notified when you added the item to the mutable list.
    mcpiroman

    mcpiroman

    1 year ago
    But isn't that annotation used to force Compose to think it is immutable - promise you don't mutate it even while you can?
    Nathan Castlehow

    Nathan Castlehow

    1 year ago
    Yeap it is to tell compose its immutable. I guess it depends on what the question is. We can add this annotation but we run the risk that someone else then uses the type in a way which isn’t truly immutable with odd results.
    My go to thread for conceptualising some of this https://kotlinlang.slack.com/archives/CJLTWPH7S/p1622465932419200