The Mediator of Web Runes
Reduce chaotic web dependencies by forcing runes to communicate via a central Leyline Hub.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Mediator
ARCANUM SCHOOL: Illusion // Telepathic Nexus
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// PURESCRIPT PATTERN //
module Arcane.Mediator where
import Prelude
import Effect (Effect)
import Effect.Console (log)
-- Mediator
type LeylineHub = { broadcast :: String -> String -> Effect Unit }
createHub :: Effect LeylineHub
createHub = pure
{ broadcast: \sender msg -> log $ "[" <> sender <> " whispers to the leyline]: " <> msg }
-- Colleague
type Mage = { name :: String, hub :: LeylineHub, speak :: String -> Effect Unit }
registerMage :: String -> LeylineHub -> Mage
registerMage name hub =
{ name
, hub
, speak: \msg -> hub.broadcast name msg
}
Runic Tags:
#behavioral
#mediator
#purescript
#runes