blob: caa9d77d43876085a8bc4e24b21f3c34b7350f5c (
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
|
class _EventLogStore extends EventEmitter {
constructor() {
/*jshint validthis: true */
super();
this.log = [];
}
getAll() {
return this.log;
}
handle(action) {
switch (action.actionType) {
case ActionTypes.LOG_ADD:
this.log.push(action.message);
this.emit("change");
break;
default:
return;
}
}
}
var EventLogStore = new _EventLogStore();
AppDispatcher.register(EventLogStore.handle.bind(EventLogStore));
var EventLogMixin = {
getInitialState(){
return {
log: EventLog.getAll()
};
},
componentDidMount(){
SettingsStore.addListener("change", this._onEventLogChange);
},
componentWillUnmount(){
SettingsStore.removeListener("change", this._onEventLogChange);
},
_onEventLogChange(){
this.setState({
log: EventLog.getAll()
});
}
};
|