80 Collection change notifications
A subscription on a collection field sees in-place List mutations as old/new value snapshots. Closing it stops notifications, not later list changes.
norm
import std.observation.onChange
class Tasks { List<String> titles = [] }
main() {
Tasks tasks = Tasks()
var subscription = tasks.titles.onChange {
printLine("${oldValue.size()} -> ${newValue.size()}")
}
tasks.titles.add("Learn")
tasks.titles.add("Build")
subscription.close()
tasks.titles.add("Publish")
printLine(tasks.titles.size())
}Expected output:
text
0 -> 1
1 -> 2
3Try it: Replace the list with an equal list and inspect whether it notifies.
Precise rules: Reference.