Mediator in ReasonML
Centralizing events in a dispatch hub.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Mediator
ARCANUM SCHOOL: Enchantment // Charm
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// REASON PATTERN //
type message = Chat(string) | Alert(string);
let broker = (msg) =>
switch (msg) {
| Chat(s) => Js.log("Broadcast: " ++ s)
| Alert(s) => Js.log("WARNING: " ++ s)
};
A single dispatcher function receives variants and routes the flows of logic, preventing the UI nodes from entangling their communication lines.
Runic Tags:
#reason
#mediator
#behavioral