🐪 OCAML METAMAGIC DIFFICULTY: Apprentice Behavioral

The Observer

Subscribing scrying orbs to ethereal shockwaves.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Observer
ARCANUM SCHOOL: Divination // Scrying Network
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// OCAML PATTERN //
type event = ManaSurge | VoidCollapse
type observer = event -> unit

let create_subject () =
  let observers = ref [] in
  let attach obs = observers := obs :: !observers in
  let notify ev = List.iter (fun f -> f ev) !observers in
  (attach, notify)

let attach, notify = create_subject ()
let () = attach (fun ev -> print_endline "Orb 1 detected event!")

The Observer is implemented through callback lists inside mutable references, allowing scrying nodes to react to events across the psychic network.

Runic Tags: #Caml Metamagic #Callbacks #Mutability #OCaml