* 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`
29 lines
592 B
JavaScript
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
|
|
};
|