5 'flight/lib/component',
7 ], function (defineComponent, dataStore) {
13 this.recount = function () {
14 var todos = this.attr.dataStore.all();
15 var all = todos.length;
16 var remaining = todos.reduce(function (memo, each) {
17 return memo += each.completed ? 0 : 1;
20 this.trigger('dataStatsCounted', {
23 completed: all - remaining,
24 filter: localStorage.getItem('filter') || ''
28 this.after('initialize', function () {
29 this.on(document, 'dataTodosLoaded', this.recount);
30 this.on(document, 'dataTodoAdded', this.recount);
31 this.on(document, 'dataTodoRemoved', this.recount);
32 this.on(document, 'dataTodoToggled', this.recount);
33 this.on(document, 'dataClearedCompleted', this.recount);
34 this.on(document, 'dataTodoToggledAll', this.recount);
38 return defineComponent(stats);