mirror of
https://github.com/mitmproxy/mitmproxy.git
synced 2024-11-25 22:30:24 +00:00
Use Facebook's dispatcher
This commit is contained in:
parent
b09dbbe209
commit
4506bafddc
File diff suppressed because one or more lines are too long
@ -6,7 +6,8 @@
|
||||
"lodash": "",
|
||||
"react": "",
|
||||
"react-router": "",
|
||||
"bootstrap": ""
|
||||
"bootstrap": "",
|
||||
"flux": ""
|
||||
},
|
||||
"devDependencies": {
|
||||
"bower": "",
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user