diff options
author | Jason <jason.daurus@gmail.com> | 2016-06-18 14:11:42 +0800 |
---|---|---|
committer | Jason <jason.daurus@gmail.com> | 2016-06-18 14:11:47 +0800 |
commit | 6c0511b06fdc359ec4c48879f803c80d7fbeb34c (patch) | |
tree | 8945be2b82dcc2eadb80284cee0493a05c956af1 /web/src/js/ducks/websocket.js | |
parent | e4addd60f1ffbb445a8c05f3fb2b6c6e61bd7b93 (diff) | |
download | mitmproxy-6c0511b06fdc359ec4c48879f803c80d7fbeb34c.tar.gz mitmproxy-6c0511b06fdc359ec4c48879f803c80d7fbeb34c.tar.bz2 mitmproxy-6c0511b06fdc359ec4c48879f803c80d7fbeb34c.zip |
[web] add app ducks
Diffstat (limited to 'web/src/js/ducks/websocket.js')
-rw-r--r-- | web/src/js/ducks/websocket.js | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/web/src/js/ducks/websocket.js b/web/src/js/ducks/websocket.js index 268c9e65..0d0556ad 100644 --- a/web/src/js/ducks/websocket.js +++ b/web/src/js/ducks/websocket.js @@ -3,17 +3,17 @@ import { AppDispatcher } from '../dispatcher.js' import * as eventLogActions from './eventLog' import * as flowActions from './flows' -const CONNECT = 'WEBSOCKET_CONNECT' -const CONNECTED = 'WEBSOCKET_CONNECTED' -const DISCONNECT = 'WEBSOCKET_DISCONNECT' -const DISCONNECTED = 'WEBSOCKET_DISCONNECTED' -const ERROR = 'WEBSOCKET_ERROR' -const MESSAGE = 'WEBSOCKET_MESSAGE' +export const CONNECT = 'WEBSOCKET_CONNECT' +export const CONNECTED = 'WEBSOCKET_CONNECTED' +export const DISCONNECT = 'WEBSOCKET_DISCONNECT' +export const DISCONNECTED = 'WEBSOCKET_DISCONNECTED' +export const ERROR = 'WEBSOCKET_ERROR' +export const MESSAGE = 'WEBSOCKET_MESSAGE' /* we may want to have an error message attribute here at some point */ const defaultState = { connected: false, socket: null } -export default function reducer(state = defaultState, action) { +export default function reduce(state = defaultState, action) { switch (action.type) { case CONNECT: @@ -52,7 +52,10 @@ export function connect() { } export function disconnect() { - return { type: DISCONNECT } + return (dispatch, getState) => { + getState().settings.socket.close() + dispatch({ type: DISCONNECT }) + } } export function onConnect() { |