MCPcopy Create free account
hub / github.com/RefactoringGuru/design-patterns-python / ConcreteMediator

Class ConcreteMediator

src/Mediator/Conceptual/main.py:34–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32
33
34class ConcreteMediator(Mediator):
35 def __init__(self, component1: Component1, component2: Component2) -> None:
36 self._component1 = component1
37 self._component1.mediator = self
38 self._component2 = component2
39 self._component2.mediator = self
40
41 def notify(self, sender: object, event: str) -> None:
42 if event == "A":
43 print("Mediator reacts on A and triggers following operations:")
44 self._component2.do_c()
45 elif event == "D":
46 print("Mediator reacts on D and triggers following operations:")
47 self._component1.do_b()
48 self._component2.do_c()
49
50
51class BaseComponent:

Callers 1

main.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected