Files
scratch-gui/src/reducers/vm.js
T
chrisgarrity 44c76e5774 Combine GUI reducers
* Export initial states for each reducer
* combine all gui reducers (excludes scratchPaint and intl)
* combine all initial states to create default guiState for preloading in www
* expect all of the gui state to be accessible at `state.scratchGui`
2018-05-21 16:54:19 -04:00

29 lines
592 B
JavaScript

import VM from 'scratch-vm';
import storage from '../lib/storage';
const SET_VM = 'scratch-gui/vm/SET_VM';
const defaultVM = new VM();
defaultVM.attachStorage(storage);
const initialState = defaultVM;
const reducer = function (state, action) {
if (typeof state === 'undefined') state = initialState;
switch (action.type) {
case SET_VM:
return action.vm;
default:
return state;
}
};
const setVM = function (vm) {
return {
type: SET_VM,
vm: vm
};
};
export {
reducer as default,
initialState as vmInitialState,
setVM
};