diff options
author | Maximilian Hils <git@maximilianhils.com> | 2014-09-15 18:08:26 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2014-09-15 18:08:26 +0200 |
commit | cbf18320cdbd05197f232da69b3c9a5391735156 (patch) | |
tree | 63b9cf8fd6a8e8fb5be6b2d5a655acf3d33b6229 /web/src/js/stores/SettingsStore.es6.js | |
parent | 9f8d2eea64d4611c1e2f7e7043fe6d3ef9a6aa40 (diff) | |
download | mitmproxy-cbf18320cdbd05197f232da69b3c9a5391735156.tar.gz mitmproxy-cbf18320cdbd05197f232da69b3c9a5391735156.tar.bz2 mitmproxy-cbf18320cdbd05197f232da69b3c9a5391735156.zip |
client-side structure
Diffstat (limited to 'web/src/js/stores/SettingsStore.es6.js')
-rw-r--r-- | web/src/js/stores/SettingsStore.es6.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/web/src/js/stores/SettingsStore.es6.js b/web/src/js/stores/SettingsStore.es6.js new file mode 100644 index 00000000..7f3a6837 --- /dev/null +++ b/web/src/js/stores/SettingsStore.es6.js @@ -0,0 +1,42 @@ +class _SettingsStore extends EventEmitter { + constructor() { + /*jshint validthis: true */ + super(); + this.settings = { version: "0.12", showEventLog: true }; //FIXME: Need to get that from somewhere. + } + getSettings() { + return this.settings; + } + handle(action) { + switch (action.actionType) { + case ActionTypes.SETTINGS_UPDATE: + this.settings = action.settings; + this.emit("change"); + break; + default: + return; + } + } +} +var SettingsStore = new _SettingsStore(); +AppDispatcher.register(SettingsStore.handle.bind(SettingsStore)); + + +var SettingsMixin = { + getInitialState(){ + return { + settings: SettingsStore.getSettings() + }; + }, + componentDidMount(){ + SettingsStore.addListener("change", this._onSettingsChange); + }, + componentWillUnmount(){ + SettingsStore.removeListener("change", this._onSettingsChange); + }, + _onSettingsChange(){ + this.setState({ + settings: SettingsStore.getSettings() + }); + } +};
\ No newline at end of file |