⚡ V SIGIL DIFFICULTY: Apprentice Behavioral

The Observer Sigil

Establishing a psychic broadcast network to notify multiple wards of a grid shift.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Observer
ARCANUM SCHOOL: Divination // Broadcasting
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// V PATTERN //
module main

interface Observer {
	update(event string)
}

struct GridMonitor {
mut:
	observers []Observer
}
fn (mut g GridMonitor) attach(o Observer) {
	g.observers << o
}
fn (g GridMonitor) broadcast(event string) {
	for o in g.observers {
		o.update(event)
	}
}

struct SecurityWard {
	id int
}
fn (w SecurityWard) update(event string) {
	println("Ward \$w.id received telemetry: \$event. Adapting defenses.")
}

fn main() {
	mut monitor := GridMonitor{}
	w1 := SecurityWard{id: 1}
	w2 := SecurityWard{id: 2}

	monitor.attach(w1)
	monitor.attach(w2)

	monitor.broadcast("DEMONIC_INCURSION_DETECTED")
}

The Observer Sigil

Instead of having your defensive wards constantly ping the network to see if danger approaches, the Observer flips the flow. Wards register to the GridMonitor, which blasts a psychic broadcast when reality starts warping. V’s arrays of interfaces elegantly handle holding diverse, decoupled listeners.

Runic Tags: #vlang #observer #behavioral #psychic-network