diff --git a/src/index.js b/src/index.js index d512dbdcb0d6493175c987778ed5185f22aec21b..3bfa737f52db778b0196009bcfecb83c96f94795 100644 --- a/src/index.js +++ b/src/index.js @@ -1,11 +1,9 @@ import GUI from './containers/gui.jsx'; -import GuiReducer, {guiInitialState, initFullScreen, initPlayer} from './reducers/gui'; +import GuiReducer, {guiInitialState, guiMiddleware, initFullScreen, initPlayer} from './reducers/gui'; import {ScratchPaintReducer} from 'scratch-paint'; import IntlReducer from './reducers/intl'; import {setFullScreen, setPlayer} from './reducers/mode'; import {setAppElement} from 'react-modal'; -import {applyMiddleware, compose} from 'redux'; -import throttle from 'redux-throttle'; const guiReducers = { intl: IntlReducer, @@ -13,8 +11,6 @@ const guiReducers = { scratchPaint: ScratchPaintReducer }; -const guiMiddleware = compose(applyMiddleware(throttle(300, {leading: true, trailing: true}))); - export { GUI as default, setAppElement, diff --git a/src/lib/app-state-hoc.jsx b/src/lib/app-state-hoc.jsx index 8093d238132689c9a601f32eb75b0dba28b9d20b..dc62aa31bca70f8a05ea90cc698d8050c811ea7c 100644 --- a/src/lib/app-state-hoc.jsx +++ b/src/lib/app-state-hoc.jsx @@ -1,25 +1,20 @@ import React from 'react'; import PropTypes from 'prop-types'; import {Provider} from 'react-redux'; -import {createStore, applyMiddleware, combineReducers, compose} from 'redux'; -import throttle from 'redux-throttle'; +import {createStore, combineReducers, compose} from 'redux'; import {intlShape} from 'react-intl'; import {IntlProvider, updateIntl} from 'react-intl-redux'; import intlReducer from '../reducers/intl.js'; -import guiReducer, {guiInitialState, initFullScreen, initPlayer} from '../reducers/gui'; +import guiReducer, {guiInitialState, guiMiddleware, initFullScreen, initPlayer} from '../reducers/gui'; import {setPlayer, setFullScreen} from '../reducers/mode.js'; import {ScratchPaintReducer} from 'scratch-paint'; const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; -const enhancer = composeEnhancers( - applyMiddleware( - throttle(300, {leading: true, trailing: true}) - ) -); +const enhancer = composeEnhancers(guiMiddleware); /* * Higher Order Component to provide redux state. If an `intl` prop is provided diff --git a/src/reducers/gui.js b/src/reducers/gui.js index 2368e2ec38b353a1cf863d38f34ce175935431dd..e28b757163b50b0c10c8265222e6bc4f877a14d8 100644 --- a/src/reducers/gui.js +++ b/src/reducers/gui.js @@ -1,4 +1,4 @@ -import {combineReducers} from 'redux'; +import {applyMiddleware, compose, combineReducers} from 'redux'; import cardsReducer, {cardsInitialState} from './cards'; import colorPickerReducer, {colorPickerInitialState} from './color-picker'; import customProceduresReducer, {customProceduresInitialState} from './custom-procedures'; @@ -14,7 +14,9 @@ import stageSizeReducer, {stageSizeInitialState} from './stage-size'; import targetReducer, {targetsInitialState} from './targets'; import toolboxReducer, {toolboxInitialState} from './toolbox'; import vmReducer, {vmInitialState} from './vm'; +import throttle from 'redux-throttle'; +const guiMiddleware = compose(applyMiddleware(throttle(300, {leading: true, trailing: true}))); const guiInitialState = { blockDrag: blockDragInitialState, @@ -75,6 +77,7 @@ const guiReducer = combineReducers({ export { guiReducer as default, guiInitialState, + guiMiddleware, initFullScreen, initPlayer };