NotificationSink

Host-agnostic sink for transient user-facing notifications.

Any UI shell (Swing toasts, web push, CLI ANSI lines, headless test collector) implements this interface; substrate code that needs to surface an event-class message receives a sink reference and calls one of the methods below. This replaces the older per-panel onMessage: (String, NotificationSeverity) -> Unit callback idiom with a single uniform contract.

Thread-safety contract

Implementations must be safe to call from any thread. The intent is that substrate code (which may emit from ksl.simulation.SimulationDispatcher.default background workers or kotlinx.coroutines IO dispatcher threads) can call into a notification sink without coordinating its own dispatcher marshalling. Implementations marshal to whatever thread they need internally (e.g. a Swing implementation uses SwingUtilities.invokeLater).

Convenience methods

The default info / warn / error methods build a NotificationSpec with the appropriate severity and delegate to emit. Callers that need a non-default dismiss duration build a NotificationSpec explicitly and call emit directly.

Inheritors

Types

Link copied to clipboard

Accumulates emitted specs into a list for assertion in tests and headless host fixtures. Thread-safe — the underlying list is synchronised so substrate code that emits from background dispatchers can target this sink without coordinating its own marshalling.

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun emit(spec: NotificationSpec)

Emit one notification. Must be safe to call from any thread — implementations marshal to whatever dispatcher they need.

Link copied to clipboard
open fun error(message: String)

Convenience: emit a NotificationSeverity.ERROR notification.

Link copied to clipboard
open fun info(message: String)

Convenience: emit an NotificationSeverity.INFO notification.

Link copied to clipboard
open fun warn(message: String)

Convenience: emit a NotificationSeverity.WARNING notification.