# events

`software.visionary:events:2026.10.13` · https://codeberg.org/eventz/api

Generic event timelines and OBSERVER contracts

Generic OBSERVER contracts over immutable, naturally ordered timestamps, with no non-JDK runtime dependencies.

## Rationale

**Why.** The JDK's <code>java.util.Observer</code> and <code>java.util.Observable</code> are deprecated since Java 9: <code>Observable</code> is a class to extend, and it delivers each notification as an untyped <code>Object</code>.

**Problem.** Modules that publish events and modules that react to them need a shared contract, and an event's time needs a type that orders the timeline without tying every module to one clock.

**Solution.** Four interfaces. <code>Event</code> is parameterized by its timestamp type, <code>Observable</code> and <code>Observer</code> by the event type, and <code>MutableObservable</code> adds registration. Storage, ordering and threading of registrations are left to the implementation, and a module that keeps one clock fixes the timestamp type in its own event.

## Key Concepts

### Event timelines

**Role.** <code>Event&lt;T extends Comparable&lt;? super T&gt;&gt;</code> reports when a fact occurred. Timestamp types must be immutable; comparability is enforced by Java and immutability is a documented contract.

### Notification

**Role.** An <code>Observable&lt;E&gt;</code> is the SUBJECT and an <code>Observer&lt;E&gt;</code> receives events through <code>update</code>. <code>MutableObservable&lt;E&gt;</code> adds registration and removal.

**Pattern.** OBSERVER

## Lane

**Purpose.** Typed OBSERVER contracts for publishing and receiving timestamped events within one process.

**Alternative.** <code>java.util.concurrent.Flow</code> when a subscriber must signal demand; <code>java.beans.PropertyChangeSupport</code> for a bean's property changes.

**When to avoid.** Asynchronous streams that need back-pressure, or events that cross a process boundary.

## Usage

An event on the JDK timeline

```java
record Recorded(java.time.Instant when) implements Event<java.time.Instant> {}
```

