diff options
author | Maximilian Hils <git@maximilianhils.com> | 2014-12-10 00:47:05 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2014-12-10 00:47:05 +0100 |
commit | e12bf19e35867f3ea69f45054decb024a75fc2b4 (patch) | |
tree | 8201f5fd9f07d46a1a659bdfa93b2176066f4961 /web/src/js/stores/eventlogstore.js | |
parent | 05bc7e8cd8382aabdd44f7bc569d2fd421c26f21 (diff) | |
download | mitmproxy-e12bf19e35867f3ea69f45054decb024a75fc2b4.tar.gz mitmproxy-e12bf19e35867f3ea69f45054decb024a75fc2b4.tar.bz2 mitmproxy-e12bf19e35867f3ea69f45054decb024a75fc2b4.zip |
web: add event store, fix all those bugs
Diffstat (limited to 'web/src/js/stores/eventlogstore.js')
-rw-r--r-- | web/src/js/stores/eventlogstore.js | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/web/src/js/stores/eventlogstore.js b/web/src/js/stores/eventlogstore.js deleted file mode 100644 index 439c2360..00000000 --- a/web/src/js/stores/eventlogstore.js +++ /dev/null @@ -1,99 +0,0 @@ -// -// We have an EventLogView and an EventLogStore: -// The basic architecture is that one can request views on the event log -// from the store, which returns a view object and then deals with getting the data required for the view. -// The view object is accessed by React components and distributes updates etc. -// -// See also: components/EventLog.react.js -function EventLogView(store, live) { - EventEmitter.call(this); - this._store = store; - this.live = live; - this.log = []; - - this.add = this.add.bind(this); - - if (live) { - this._store.addListener(ActionTypes.ADD_EVENT, this.add); - } -} -_.extend(EventLogView.prototype, EventEmitter.prototype, { - close: function () { - this._store.removeListener(ActionTypes.ADD_EVENT, this.add); - }, - getAll: function () { - return this.log; - }, - add: function (entry) { - this.log.push(entry); - if (this.log.length > 200) { - this.log.shift(); - } - this.emit("change"); - }, - add_bulk: function (messages) { - var log = messages; - var last_id = log[log.length - 1].id; - var to_add = _.filter(this.log, function (entry) { - return entry.id > last_id; - }); - this.log = log.concat(to_add); - this.emit("change"); - } -}); - - -function _EventLogStore() { - EventEmitter.call(this); -} -_.extend(_EventLogStore.prototype, EventEmitter.prototype, { - getView: function (since) { - var view = new EventLogView(this, !since); - return view; - /* - //TODO: Really do bulk retrieval of last messages. - window.setTimeout(function () { - view.add_bulk([ - { - id: 1, - message: "Hello World" - }, - { - id: 2, - message: "I was already transmitted as an event." - } - ]); - }, 100); - - var id = 2; - view.add({ - id: id++, - message: "I was already transmitted as an event." - }); - view.add({ - id: id++, - message: "I was only transmitted as an event before the bulk was added.." - }); - window.setInterval(function () { - view.add({ - id: id++, - message: "." - }); - }, 1000); - return view; - */ - }, - handle: function (action) { - switch (action.type) { - case ActionTypes.ADD_EVENT: - this.emit(ActionTypes.ADD_EVENT, action.data); - break; - default: - return; - } - } -}); - - -var EventLogStore = new _EventLogStore(); -AppDispatcher.register(EventLogStore.handle.bind(EventLogStore));
\ No newline at end of file |