⚙️ JSONNET RUNE DIFFICULTY: Adept Behavioral

The Observer of Jsonnet

Distributing state changes to interested parties.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Observer
ARCANUM SCHOOL: Divination // Omniscience
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// JSONNET PATTERN //
local EventBus(eventData, observers) =
  [obs(eventData) for obs in observers];

local EmailObserver(data) = "Emailing " + data;
local LogObserver(data) = "Logging " + data;

{
  notifications: EventBus("System Crash", [EmailObserver, LogObserver])
}

An EventBus function passes payloads directly to a list of observer functions. A reactive array reflects the myriad consequences of a single triggered event.

Runic Tags: #behavioral #observer #jsonnet