The Observer
Defines a one-to-many dependency, alerting all bonded familiars when a core locus changes state.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Observer
ARCANUM SCHOOL: Divination // Binding
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// TCL PATTERN //
oo::class create LeylineCore {
variable familiars state
constructor {} { set familiars {}; set state "Stable" }
method attach {familiar} { lappend familiars $familiar }
method setState {newState} {
set state $newState
my notify
}
method notify {} {
foreach f $familiars {
$f update $state
}
}
}
oo::class create DaemonFamiliar {
variable name
constructor {n} { set name $n }
method update {state} {
puts "Familiar $name feels the tremor: Leyline is now $state"
}
}
set core [LeylineCore new]
$core attach [DaemonFamiliar new "Null"]
$core attach [DaemonFamiliar new "Void"]
$core setState "Corrupted by Neon"
The Observer
Magic in Tcl is inherently event-driven. The Observer pattern formally binds multiple daemon familiars to a central energy core. When the core pulses with an anomalous spike, the change ripples through the event loop, notifying all bound entities synchronously to react.
Runic Tags:
#behavioral
#observer
#event-loop
#bindings