blob: e9e2ee7784f3715c32eccb94dfc55a6fa25ddc4b (
plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
class EventEmitter {
constructor(){
this.listeners = {};
}
emit(event){
if(!(event in this.listeners)){
return;
}
this.listeners[event].forEach(function (listener) {
listener(event, this);
}.bind(this));
}
addListener(event, f){
this.listeners[event] = this.listeners[event] || [];
this.listeners[event].push(f);
}
removeListener(event, f){
if(!(event in this.listeners)){
return false;
}
var index = this.listeners.indexOf(f);
if (index >= 0) {
this.listeners.splice(this.listeners.indexOf(f), 1);
}
}
}
var FLOW_CHANGED = "flow.changed";
class FlowStore extends EventEmitter{
constructor() {
super();
this.flows = [];
}
getAll() {
return this.flows;
}
close(){
console.log("FlowStore.close()");
this.listeners = [];
}
emitChange() {
return this.emit(FLOW_CHANGED);
}
addChangeListener(f) {
this.addListener(FLOW_CHANGED, f);
}
removeChangeListener(f) {
this.removeListener(FLOW_CHANGED, f);
}
}
class DummyFlowStore extends FlowStore {
constructor(flows) {
super();
this.flows = flows;
}
addFlow(flow) {
this.flows.push(flow);
this.emitChange();
}
}
var SETTINGS_CHANGED = "settings.changed";
class Settings extends EventEmitter {
constructor(){
super();
this.settings = false;
}
getAll(){
return this.settings;
}
emitChange() {
return this.emit(SETTINGS_CHANGED);
}
addChangeListener(f) {
this.addListener(SETTINGS_CHANGED, f);
}
removeChangeListener(f) {
this.removeListener(SETTINGS_CHANGED, f);
}
}
class DummySettings extends Settings {
constructor(settings){
super();
this.settings = settings;
}
update(obj){
_.merge(this.settings, obj);
this.emitChange();
}
}
|