onStateChanged

abstract fun onStateChanged(oldState: T, newState: T)

Called when a state change occurs.

This method should be fast and non-blocking. If heavy processing is required, it should be performed asynchronously.

Observers should be resilient to exceptions - an exception in one observer should not affect other observers or the state transition.

Parameters

oldState

The previous state before the change

newState

The new state after the change