p5.js-web-editor/client/modules/IDE/reducers/ide.js

32 lines
701 B
JavaScript
Raw Normal View History

2016-06-22 21:58:23 +02:00
import * as ActionTypes from '../../../constants';
2016-05-11 22:13:17 +02:00
const initialState = {
2016-07-08 20:57:22 +02:00
isPlaying: false,
selectedFile: '1'
2016-06-24 00:29:55 +02:00
};
2016-05-11 22:13:17 +02:00
const ide = (state = initialState, action) => {
2016-06-24 00:29:55 +02:00
switch (action.type) {
case ActionTypes.TOGGLE_SKETCH:
return {
isPlaying: !state.isPlaying
};
case ActionTypes.START_SKETCH:
return {
isPlaying: true
};
case ActionTypes.STOP_SKETCH:
return {
isPlaying: false
};
2016-07-08 20:57:22 +02:00
case ActionTypes.SET_SELECTED_FILE:
case ActionTypes.SET_PROJECT:
case ActionTypes.NEW_PROJECT:
return Object.assign({}, state, { selectedFile: action.selectedFile });
2016-06-24 00:29:55 +02:00
default:
return state;
}
};
2016-05-11 22:13:17 +02:00
2016-06-24 00:29:55 +02:00
export default ide;