aboutsummaryrefslogtreecommitdiffstats
path: root/web/src
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2015-01-01 16:59:58 +1300
committerAldo Cortesi <aldo@nullcube.com>2015-01-01 16:59:58 +1300
commit4506bafddc7e9f728205a86801a4403e07488575 (patch)
tree6998061a18dfc3a770f6f5aad81a5a1f328f08f9 /web/src
parentb09dbbe20934e0da9fe45e254f74719e5e63423f (diff)
downloadmitmproxy-4506bafddc7e9f728205a86801a4403e07488575.tar.gz
mitmproxy-4506bafddc7e9f728205a86801a4403e07488575.tar.bz2
mitmproxy-4506bafddc7e9f728205a86801a4403e07488575.zip
Use Facebook's dispatcher
Diffstat (limited to 'web/src')
-rw-r--r--web/src/js/dispatcher.js25
1 files changed, 4 insertions, 21 deletions
diff --git a/web/src/js/dispatcher.js b/web/src/js/dispatcher.js
index 9a5dd3dd..040c34db 100644
--- a/web/src/js/dispatcher.js
+++ b/web/src/js/dispatcher.js
@@ -1,30 +1,13 @@
+
+var flux = require("flux");
+
const PayloadSources = {
VIEW: "view",
SERVER: "server"
};
-function Dispatcher() {
- this.callbacks = [];
-}
-Dispatcher.prototype.register = function (callback) {
- this.callbacks.push(callback);
-};
-Dispatcher.prototype.unregister = function (callback) {
- var index = this.callbacks.indexOf(callback);
- if (index >= 0) {
- this.callbacks.splice(index, 1);
- }
-};
-Dispatcher.prototype.dispatch = function (payload) {
- console.debug("dispatch", payload);
- for (var i = 0; i < this.callbacks.length; i++) {
- this.callbacks[i](payload);
- }
-};
-
-
-AppDispatcher = new Dispatcher();
+AppDispatcher = new flux.Dispatcher();
AppDispatcher.dispatchViewAction = function (action) {
action.source = PayloadSources.VIEW;
this.dispatch(action);