The Observer Pattern
Notifying multiple magical wards of a significant event.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Observer
ARCANUM SCHOOL: Divination // Telepathy
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// SWIFT PATTERN //
protocol Observer: AnyObject {
func update(threat: String)
}
class Watchtower {
private var observers: [Observer] = []
func add(_ observer: Observer) { observers.append(observer) }
func alert(threat: String) {
observers.forEach { $0.update(threat: threat) }
}
}
The Observer: The Watchtower’s Warning
The Observer establishes a telepathic link where the Watchtower can notify multiple dependent wards of incoming threats instantly.
Runic Tags:
#swift
#design-pattern
#behavioral