The Observer Hex
Reacting functionally to changes in central configuration.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Observer
ARCANUM SCHOOL: Divination // Pure Environment Hexes
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
let
# Subject: A central configuration that triggers observers
config = { debug = true; target = "x86_64-linux"; };
# Observers (Functions reacting to the subject's state)
loggerObserver = cfg:
if cfg.debug then "Logging Enabled" else "Logging Disabled";
compilerObserver = cfg:
"Compiling for ''${cfg.target}";
# Notifier (Applying observers to the subject)
notify = subject: observers:
map (obs: obs subject) observers;
in
notify config [ loggerObserver compilerObserver ]
In an immutable context, the Observer pattern translates to mapping functions over a state object. The subject does not actively push updates in real-time, but rather, observers are applied to the finalized configuration to yield the reactive derivations.
Runic Tags:
#behavioral
#observer
#nix
#reactivity