EventStore
Persists task completion events to durable storage so they survive app termination.
Problem it solves
TaskMonitor is in-memory. If a task completes while the app is in the background (killed by OS), the Success/Failed event is emitted into the void. On cold launch, the UI has no way to know what happened.
Solution
EventStore writes terminal states to disk. On app startup, call replayAll to re-emit all unread events through TaskMonitor, updating the UI with missed results.
Usage
// At app startup (before UI renders):
val store = SqlDelightEventStore(database)
TaskMonitor.install(store)
TaskMonitor.replayPendingEvents()Functions
Deletes all events older than olderThanMillis milliseconds that have already been replayed. Call periodically to prevent unbounded storage growth.
Persists a terminal task state to durable storage. Only called for terminal states: TaskState.Success, TaskState.Failed (willRetry=false), and TaskState.Cancelled.