StateObserver

fun interface StateObserver<T>

Interface for observing state changes.

State observers are notified when state transitions occur, allowing for reactive programming patterns and side effects to be handled separately from state logic.

Parameters

T

The type of state being observed

Functions

Link copied to clipboard
fun <T> StateObserver<T>.filter(predicate: (T, T) -> Boolean): StateObserver<T>

Creates a StateObserver that only reacts when a predicate is satisfied.

Link copied to clipboard
inline fun <T, R : T> StateObserver<T>.filterType(): StateObserver<T>

Creates a StateObserver that only reacts to specific state types.

Link copied to clipboard

Creates a StateObserver that only reacts to actual state changes (not same state).

Link copied to clipboard

Convenience observer that only cares about the new state.

Link copied to clipboard
abstract fun onStateChanged(oldState: T, newState: T)

Called when a state change occurs.