aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/store/view.js
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2014-12-10 15:25:40 +0100
committerMaximilian Hils <git@maximilianhils.com>2014-12-10 15:25:40 +0100
commit7e40b8ab09d6d605307342fbfa21129ca15ff055 (patch)
tree3ffbd6263f8550bea9c1cb847b0f4178c1499733 /web/src/js/store/view.js
parentd2feaf5d84820e75e3931522d889748563972c75 (diff)
downloadmitmproxy-7e40b8ab09d6d605307342fbfa21129ca15ff055.tar.gz
mitmproxy-7e40b8ab09d6d605307342fbfa21129ca15ff055.tar.bz2
mitmproxy-7e40b8ab09d6d605307342fbfa21129ca15ff055.zip
web: implement settings store, modularize store
Diffstat (limited to 'web/src/js/store/view.js')
-rw-r--r--web/src/js/store/view.js18
1 files changed, 15 insertions, 3 deletions
diff --git a/web/src/js/store/view.js b/web/src/js/store/view.js
index 261429b2..56bc4dbd 100644
--- a/web/src/js/store/view.js
+++ b/web/src/js/store/view.js
@@ -13,13 +13,25 @@ function StoreView(store, filt, sortfun) {
sortfun = sortfun || default_sort;
this.store = store;
- this.store._views.push(this);
- this.recalculate(this.store._list, filt, sortfun);
+
+ this.add = this.add.bind(this);
+ this.update = this.update.bind(this);
+ this.remove = this.remove.bind(this);
+ this.recalculate = this.recalculate.bind(this);
+ this.store.addListener("add", this.add);
+ this.store.addListener("update", this.update);
+ this.store.addListener("remove", this.remove);
+ this.store.addListener("recalculate", this.recalculate);
+
+ this.recalculate(this.store.list, filt, sortfun);
}
_.extend(StoreView.prototype, EventEmitter.prototype, {
close: function () {
- this.store._views = _.without(this.store._views, this);
+ this.store.removeListener("add", this.add);
+ this.store.removeListener("update", this.update);
+ this.store.removeListener("remove", this.remove);
+ this.store.removeListener("recalculate", this.recalculate);
},
recalculate: function (elems, filt, sortfun) {
if (filt) {