File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
patterns/mediator/conceptual Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ # State Pattern
2+ State is a behavioral design pattern that lets an object alter its behavior when its internal state
3+ changes. It appears as if the object changed its class.
4+
5+ Tutorial: [ here] ( https://refactoring.guru/design-patterns/mediator ) .
6+
7+ ## Diagram:
8+ ![ image] ( https://user-images.githubusercontent.com/8049534/173237874-971dd4e7-2e74-4cac-bcea-77b88255adad.png )
9+
10+ ### Client code:
11+ ``` dart
12+ void main() {
13+ final component1 = Component1();
14+ final component2 = Component2();
15+
16+ ConcreteMediator(component1, component2);
17+
18+ component1.doOne();
19+ print('');
20+ component2.doTwo();
21+ }
22+ ```
23+
24+ ### Output:
25+ ```
26+ call Component1.doOne()
27+ ConcreteMediator.notify(event: "doOne")
28+ ConcreteMediator.reactComponentOne()
29+ use component2.name = "Two"
30+
31+ call Component2.doTwo()
32+ ConcreteMediator.notify(event: "doTwo")
33+ ConcreteMediator.reactComponentTwo()
34+ use component1.sate = "Cmp1"
35+ ```
36+
You can’t perform that action at this time.
0 commit comments