Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function test_handleAction() {
const reducer = handleAction(INCREMENT, (state, action: ActionType) => {
assert(action.payload, (x: number) => {})
// $ExpectError
assert(action.payload, (x: string) => {})
}, initState)
}
function test_handleAction() {
const reducer = handleAction(INCREMENT, (state, action: ActionType) => {
assert(action.payload, (x: number) => {})
// $ExpectError
assert(action.payload, (x: string) => {})
}, initState)
}
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 });
}
};
/* global require */
const { applyMiddleware, createStore, compose } = require("redux");
const { logger } = require("redux-logger");
const { createActions, handleActions } = require("redux-actions");
const { ProjectChangeListener } = require("./project");
const actions = createActions(
"USER_LOGGED_IN",
"PROJECT_SELECTED",
"RESOURCES_CHANGED",
"RESOURCE_SELECTED",
"DATA_SYNCHRONIZED"
);
const reducer = handleActions({
[actions.userLoggedIn]: (state, action) => ({
...state,
user: action.payload
}),
[actions.projectSelected]: (state, action) => ({
...state,
// @flow
import { createActions } from 'redux-actions'
import typeToReducer from 'type-to-reducer'
import I18n from '../../i18n'
const actions = createActions('SET_LANGUAGE')
const initialState: string = I18n.currentLocale()
const reducer = typeToReducer(
{
[actions.setLanguage]: (state, action) => action.payload
},
initialState
)
export { actions }
export default reducer
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)