We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a546cff commit be8fea5Copy full SHA for be8fea5
Design Pattern in JavaScript/BridgePattern.js
@@ -0,0 +1,30 @@
1
+// Abstraction
2
+class GUIComponent {
3
+ constructor(platform) {
4
+ this.platform = platform;
5
+ }
6
+
7
+ render() {
8
+ this.platform.render();
9
10
+}
11
12
+// Implementation
13
+class WindowsGUI {
14
15
+ console.log('Rendering GUI component on Windows...');
16
17
18
19
+class MacOSGUI {
20
21
+ console.log('Rendering GUI component on MacOS...');
22
23
24
25
+// Usage
26
+const windowsGUIComponent = new GUIComponent(new WindowsGUI());
27
+windowsGUIComponent.render(); // Output: "Rendering GUI component on Windows..."
28
29
+const macosGUIComponent = new GUIComponent(new MacOSGUI());
30
+macosGUIComponent.render(); // Output: "Rendering GUI component on MacOS..."
0 commit comments