How to use the redux.combineReducers function in redux

To help you get started, we’ve selected a few redux 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 ueewbdy93 / wedding-screen / src / core / root-reducer.ts View on Github external
// tslint:disable-next-line:no-empty-interface
interface IStoreEnhancerState { }
export type RootAction = CommentsActionTypes |
  SlideActionTypes |
  GameActionTypes |
  $Call;

export interface IRootState extends IStoreEnhancerState {
  comment: ICommentState;
  slide: SlideState;
  game: GameState;
  mode: Mode;
}

export const rootReducer: Reducer = combineReducers({
  comment: commentsReducer,
  slide: slideReducer,
  game: gameReducer,
  mode: (state = Mode.Slide, action: RootAction) => {
    switch (action.type) {
      case getType(setMode):
        return action.mode;
      default:
        return state;
    }
  },
});
github firebug / rdp-inspector / data / inspector / reducers / index.js View on Github external
define(function(require, exports/*, module*/) {

"use strict";

// Redux
const { combineReducers } = require("redux");

// RDP Inspector
const global = require("./global");
const actors = require("./actors");
const packets = require("./packets");

var rootReducer = combineReducers({ global, actors, packets });

// Exports from this module
exports.rootReducer = rootReducer;
});
github olalonde / deisdash / reducers / index.js View on Github external
} else if (type === 'DEL_APP_DOMAIN') {
    // TODO: handle pending and error
    if (success) {
      const { results } = state
      return {
        ...state,
        results: results.filter((d) => d.domain !== metadata.domain),
      }
    }
  }
  return state
}

// @TODO: refactor this, lots of copy/paste
// @TODO: when pending, reset object
const activeApp = combineReducers({
  config, overview, builds, releases, domains, logs, perms,
})

const controllerInfo = (state = null, { type, payload, success, pending, error }) => {
  if (type !== 'CONTROLLER_INFO') return state
  if (success) {
    return { ...payload, isValid: true }
  } else if (pending) {
    return null
  } else if (error) {
    return { isValid: false }
  }
}

const ui = combineReducers({
  login: (state = {}, { type, payload, error, success }) => {
github yugabyte / yugabyte-db / managed / ui / src / reducers / index.js View on Github external
// Copyright (c) YugaByte, Inc.

import { combineReducers } from 'redux';
import CustomerReducer from './reducer_customer';
import CloudReducer from './reducer_cloud';
import UniverseReducer from './reducer_universe';
import ModalReducer from './reducer_modal';
import GraphReducer from './reducer_graph';
import TasksReducer from './reducer_tasks';
import TablesReducer from './reducer_tables';
import { reducer as formReducer } from 'redux-form';

const rootReducer = combineReducers({
  customer: CustomerReducer,
  cloud: CloudReducer,
  universe: UniverseReducer,
  form: formReducer,
  modal: ModalReducer,
  graph: GraphReducer,
  tasks: TasksReducer,
  tables: TablesReducer
});

export default rootReducer;
github department-of-veterans-affairs / vets-website / src / js / common / store / index.js View on Github external
import _ from 'lodash/fp';
import { createStore, applyMiddleware, compose, combineReducers } from 'redux';
import thunk from 'redux-thunk';
import { scheduledDowntime } from '../reducers';
import login from '../../login/reducers/login';
import feedback from '../../feedback/reducers';
import profile from '../../user-profile/reducers/profile';

export const commonReducer = {
  user: combineReducers({
    login,
    profile
  }),
  feedback,
  scheduledDowntime
};

export default function createCommonStore(appReducer = {}) {
  const reducer = _.assign(appReducer, commonReducer);
  const useDevTools = __BUILDTYPE__ === 'development' && window.devToolsExtension;

  return createStore(combineReducers(reducer), compose(
    applyMiddleware(thunk), useDevTools ? window.devToolsExtension() : f => f));
}
github exactpro / sailfish-core / FrontEnd / Sailfish-JS-report / src / store / store.ts View on Github external
export function createAppStore() {
    const liveUpdateService = new LiveUpdateService(), 
        thunkExtra: ThunkExtraArgument = { liveUpdateService },
        middleware = [
            thunk.withExtraArgument(thunkExtra),
            urlHandler
        ];

    const store = createStore(
        combineReducers({
            report: reportReducer,
            selected: selectedReducer,
            view: viewReducer,
            filter: filterReducer,
            machineLearning: machineLearningReducer
        }),
        initialAppState,
        composeWithDevTools(applyMiddleware(...middleware))
    );

    initLiveUpdateEventSource(store, liveUpdateService);
    initBroserHistoryEventSource(store);

    return store;
}
github mthorry / tv-lineup-app / frontend-my-lineup-app / src / index.js View on Github external
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
import { BrowserRouter as Router } from 'react-router-dom'
import { createStore, combineReducers, applyMiddleware } from 'redux'
import { Provider } from 'react-redux'
import showReducer from './reducers/showReducer'
import episodeReducer from './reducers/episodeReducer'
import searchReducer from './reducers/searchReducer'
import extrasReducer from './reducers/extrasReducer'
import thunk from 'redux-thunk'
import { composeWithDevTools } from 'redux-devtools-extension';
import 'semantic-ui-css/semantic.min.css';

const rootReducer = combineReducers({ search: searchReducer, show: showReducer, extras: extrasReducer, episode: episodeReducer })
const store = createStore(rootReducer, composeWithDevTools(applyMiddleware(thunk)))

ReactDOM.render(, document.getElementById('root'));
registerServiceWorker();
github macarthur-lab / gnomadjs / packages / gnomad / src / reducers / genes.js View on Github external
}
    default:
      return state
  }
}

const allGeneNames = (state = [], action) => {
  switch (action.type) {
    case geneTypes.RECEIVE_GENE_DATA:
      return R.uniq([...state, action.geneName])
    default:
      return state
  }
}

const genes = combineReducers({
  isFetching,
  byGeneName,
  allGeneNames,
})

export default genes

export const getGene = (state, geneName) => state.byGeneName[geneName]

export const getAllVariantsInGeneForDataset = (state, geneName, datasetId) => {
  return state.byGeneName[geneName].variantIdsByDataset[datasetId]
}
github lappis-unb / BotFlow / app / src / ducks / index.js View on Github external
function configureStore() {
  return createStore(
    combineReducers({
      intent: intentReducer,
      utter: utterReducer,
      story: storyReducer
    }),
    applyMiddleware(thunk)
  );
}