changes

infix fun changes(observer: (oldState: S, newState: S) -> Unit)

Adds an observer to watch state changes.

Example:

watching changes { old, new -> println("$old -> $new") }