receptor/src/reducers/socket.js

19 lines
447 B
JavaScript
Raw Normal View History

2017-09-08 16:40:59 +02:00
import { SOCKET_STATE, SOCKET_UPDATE, SOCKET_URI } from '../actions/socket';
2017-09-08 06:55:47 +02:00
export default function socket(_state = {
state: SOCKET_STATE.DISCONNECTED,
2017-09-08 16:40:59 +02:00
reason: null,
2017-10-13 06:34:26 +02:00
uri: null,
password: null,
2017-09-08 06:55:47 +02:00
}, action) {
2017-09-08 16:40:59 +02:00
const { state, reason, uri } = action;
switch (action.type) {
2017-09-08 06:55:47 +02:00
case SOCKET_UPDATE:
return { ..._state, state, reason };
2017-09-08 16:40:59 +02:00
case SOCKET_URI:
2017-10-13 06:34:26 +02:00
return { ..._state, ...uri, };
default:
2017-09-08 06:55:47 +02:00
return _state;
}
}