Skip to content

@Mediator

Marker-only — documents a mediator that coordinates colleagues without tight coupling.

KindMarker-only class
Backendslegacy, stage3
Requires generateNo

Example

ts
import { Mediator } from 'lombok-typescript/legacy';

@Mediator
class ChatRoom {
  private users: { name: string; send(room: ChatRoom, msg: string): void }[] = [];

  join(user: { name: string; send(room: ChatRoom, msg: string): void }) {
    this.users.push(user);
  }

  broadcast(from: string, message: string) {
    for (const user of this.users) {
      if (user.name !== from) user.send(this, message);
    }
  }
}

The decorator does not wire colleagues automatically — it marks the architectural role.

Released under the MIT License.