@scion-scxml/redux-devtools-scion-monitor
Version:
Redux monitor to visualize SCXML state
25 lines (20 loc) • 659 B
JavaScript
import { UPDATE_SCROLL_TOP, START_CONSECUTIVE_TOGGLE } from './actions';
function initialScrollTop(props, state = 0, action) {
if (!props.preserveScrollTop) {
return 0;
}
return action.type === UPDATE_SCROLL_TOP ?
action.scrollTop :
state;
}
function startConsecutiveToggle(props, state, action) {
return action.type === START_CONSECUTIVE_TOGGLE ?
action.id :
state;
}
export default function reducer(props, state = {}, action) {
return {
initialScrollTop: initialScrollTop(props, state.initialScrollTop, action),
consecutiveToggleStartId: startConsecutiveToggle(props, state.consecutiveToggleStartId, action)
};
}