-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
43 lines (35 loc) · 1.12 KB
/
app.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
(function () {
return {
eventList: [],
events: {
'app.activated': 'initialize',
'*.changed': 'onChange',
'click .getEvents': 'onGetEventsClick'
},
initialize: function () {
this.switchTo('layout');
console.log('app loaded');
},
onChange: function(e) {
//console.log(_.pick(e, 'propertyName'))
this.eventList.push(e);
},
onGetEventsClick: function(e) {
e.preventDefault();
var fullEventList = '';
var eventCount = {};
_.each(this.eventList, function(evt) {
fullEventList += helpers.fmt("%@, new value: '%@'\n", evt.propertyName, evt.newValue);
eventCount[evt.propertyName] = eventCount[evt.propertyName] ? ++eventCount[evt.propertyName] : 1;
});
var multiTriggeredEvents = _.omit(eventCount, function(val) {
return val === 1;
});
console.log('\nEvents that triggered multiple times since last getEvents:');
console.log(multiTriggeredEvents);
console.log('All events triggered since last getEvents:');
console.log(fullEventList);
this.eventList = [];
}
};
}());