Compose Compiler can compare a tree of nodes. But ...
# compose
h
Compose Compiler can compare a tree of nodes. But can it compare different nodes with built-in lists of other nodes too? Usecase:
data class Foo(val bar: List<Bar>) { data class Bar(val i: Int) }
Can Compose generate the difference of
Foo(emptyList())
and
Foo(listOf(Bar(1))
and
Foo(listOf(Bar(42))
? At the end, I would like to use Compose as a general tree diff tool with my own tree implementation by using difference instances of my tree.
z
Compose doesn't compare trees of nodes. It generates effectively change lists by performing composition, then applies those changes to the tree. So to answer your question, nope. Compose is not a diff tool.
h
Ah, okay. But would you able do use it as a diff tool too, iff the data is not given, but generated during compositions? With a custom compose applier, you could store the changes and return it later?
z
Compose generates and updates a tree data structure from an execution of composable functions. Trying to use it for something else might work, but will probably be pretty hacky and more complex than it's worth