✨ ARCANUM RUNE DIFFICULTY: Apprentice Behavioral

The Observer Familiar

A one-to-many dependency where familiars are notified automatically of their master's state changes.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Observer
ARCANUM SCHOOL: Divination // Clairvoyance
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
effect observable
  ctl notify(event: string) : ()

fun with-familiars(action: () -> <observable|e> a) : e a
  with handler
    ctl notify(ev)
      println("Raven saw: " ++ ev)
      println("Cat felt: " ++ ev)
      resume(())
  action()

pub fun main()
  with with-familiars
  notify("Master cast a spell")
  notify("Master is sleeping")
Runic Tags: #koka #observer #pub-sub