How to use the redux-actions.handleActions function in redux-actions

To help you get started, we’ve selected a few redux-actions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Temzasse / reducktion / src / reducktion.js View on Github external
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 });
    }
  };
github robinweser / react-controlled-form / modules / utils / handleReducer.js View on Github external
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)
}
github tracyxiong1 / react-native-example / src / reducers / counter.js View on Github external
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;
github podlove / podlove-ui / packages / player / state / content / reducer.js View on Github external
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
)
github leonardodino / forex-web-app / src / utils / redux.js View on Github external
export const handleActions = (reducerMap, initialState = {}, options) =>
  originalHandle(reducerMap, initialState, options)
github podlove / podlove-ui / packages / player / state / lifecycle.js View on Github external
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
)
github AhKi / oh-my-desk / app / store / reducers / personal / search / filter.js View on Github external
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;
github topcoder-platform / community-app / src / shared / reducers / quality-assurance / repositories.js View on Github external
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 || {});
}
github podlove / podlove-ui / packages / player / state / subscribe-button / reducer.js View on Github external
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
)

redux-actions

Flux Standard Action utlities for Redux

MIT
Latest version published 4 months ago

Package Health Score

80 / 100
Full package analysis