Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const _run = () => {
// Run model reactions function to get rest of the reducer
if (model.reactions) {
const fromDeps = model.reactions({ initialState, deps: dependencies });
reducerHandlers = { ...reducerHandlers, ...fromDeps };
}
reducer = handleActions(reducerHandlers, initialState);
if (model.sagas) {
sagas = model.sagas({ types, deps: dependencies });
}
};
export default function handleReducer(actions, initialState) {
const actionHandler = Object.keys(actions).reduce((handler, type) => {
handler[type] = (state, action) => {
if (action.payload && action.payload.errors) {
console.log(action.payload.message, null, 'Something went wrong', 'Ok')
return state
}
return actions[type](state, action)
}
return handler
}, {})
return handleActions(actionHandler, initialState)
}
import { Map } from 'immutable';
import { handleActions } from 'redux-actions';
const initialState = Map({ counter: 0 });
const reducer = handleActions({
increment: state => state.update('counter', n => n + 1),
decrement: state => state.update('counter', n => n - 1),
}, initialState);
export default reducer;
import { handleActions } from 'redux-actions'
import { SELECT_CONTENT } from '@podlove/player-actions/types'
export const INITIAL_STATE = 'episode'
const update = (state, content) =>
['show', 'episode', 'chapter', 'time'].includes(content) ? content : state
export const reducer = handleActions(
{
[SELECT_CONTENT]: (state, { payload }) => update(state, payload)
},
INITIAL_STATE
)
export const handleActions = (reducerMap, initialState = {}, options) =>
originalHandle(reducerMap, initialState, options)
import { handleActions } from 'redux-actions'
import { READY, CONSTRUCTED, INIT } from '@podlove/player-actions/types'
export const INITIAL_STATE = null
export const reducer = handleActions(
{
[CONSTRUCTED]: () => 'constructed',
[INIT]: () => 'init',
[READY]: () => 'ready'
},
INITIAL_STATE
)
import { handleActions } from 'redux-actions';
import * as TYPES from 'actions/constant/actionTypes';
const initialState = 'ALL';
const filterReducer = handleActions({
[TYPES.SEARCH_SET_FILTER]: (state, action) => action.payload.filter,
}, initialState);
export default filterReducer;
function create(initialState) {
return handleActions({
[actions.qualityAssurance.getRepositoriesInit](state) {
return {
...state,
repositories: null,
failed: false,
loading: true,
dateTime: Date.now(),
};
},
[actions.qualityAssurance.getRepositoriesDone]: onDone,
}, initialState || {});
}
import { handleActions } from 'redux-actions'
import { CONSTRUCTED } from '@podlove/player-actions/types'
import * as config from '@podlove/player-config'
export const INITIAL_STATE = false
export const reducer = handleActions(
{
[CONSTRUCTED]: (_, { payload }) => !!config.subscribeButton(payload)
},
INITIAL_STATE
)