vn-verdnaturachat/app/reducers/connect.js

38 lines
665 B
JavaScript
Raw Normal View History

2017-08-17 01:06:31 +00:00
import { METEOR } from '../actions/actionsTypes';
const initialState = {
connecting: false,
connected: false,
errorMessage: '',
failure: false
};
export default function connect(state = initialState, action) {
switch (action.type) {
case METEOR.REQUEST:
2017-11-13 12:58:35 +00:00
return {
...state,
2017-08-17 01:06:31 +00:00
connecting: true
};
case METEOR.SUCCESS:
2017-11-13 12:58:35 +00:00
return {
...state,
2017-08-17 01:06:31 +00:00
connecting: false,
connected: true,
failure: false
};
case METEOR.FAILURE:
2017-11-13 12:58:35 +00:00
return {
...state,
2017-08-17 01:06:31 +00:00
connecting: false,
connected: false,
failure: true,
errorMessage: action.err
};
2017-08-17 16:55:47 +00:00
case METEOR.DISCONNECT:
return initialState;
2017-08-17 01:06:31 +00:00
default:
return state;
}
}