-
Notifications
You must be signed in to change notification settings - Fork 75
/
Bridge.js
62 lines (51 loc) · 1.32 KB
/
Bridge.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
'use strict';
class Abstraction {
constructor() {
console.log('Abstraction Class created');
}
operation() {
console.log('Abstraction.operation invoked');
this.imp.operationImp();
}
}
class RefinedAbstraction extends Abstraction {
constructor() {
super()
console.log('RefinedAbstraction Class created');
}
setImp(imp) {
console.log('RefinedAbstraction.setImp invoked');
this.imp = imp
}
}
class Implementor {
constructor() {
console.log('Implementor Class created');
}
operationImp() {
console.log('Implementor.operationImp invoked');
}
}
class ConcreteImplementorA extends Implementor {
constructor() {
super()
console.log('ConcreteImplementorA Class created');
}
operationImp() {
console.log('ConcreteImplementorA.operationImp invoked');
}
}
class ConcreteImplementorB extends Implementor {
constructor() {
super()
console.log('ConcreteImplementorB Class created');
}
operationImp() {
console.log('ConcreteImplementorB.operationImp invoked');
}
}
var abstraction = new RefinedAbstraction();
abstraction.setImp(new ConcreteImplementorA());
abstraction.operation();
abstraction.setImp(new ConcreteImplementorB());
abstraction.operation();