How to use redux-actions - 10 common examples

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 flow-typed / flow-typed / definitions / npm / redux-actions_v2.x.x / flow_v0.34.x-v0.38.x / test_handleAction.js View on Github external
function test_handleAction() {
  const reducer = handleAction(INCREMENT, (state, action: ActionType) => {
    assert(action.payload, (x: number) => {})

    // $ExpectError
    assert(action.payload, (x: string) => {})
  }, initState)
}
github flow-typed / flow-typed / definitions / npm / redux-actions_v2.x.x / flow_v0.39.x- / test_handleAction.js View on Github external
function test_handleAction() {
  const reducer = handleAction(INCREMENT, (state, action: ActionType) => {
    assert(action.payload, (x: number) => {})

    // $ExpectError
    assert(action.payload, (x: string) => {})
  }, initState)
}
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 performant-software / DM / src / main / resources / static / js / main.js View on Github external
/* 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,
github phanhoangloc / react-native-boilerplate / src / modules / Language / Language.reducer.js View on Github external
// @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
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)

redux-actions

Flux Standard Action utlities for Redux

MIT
Latest version published 4 months ago

Package Health Score

78 / 100
Full package analysis