How to use redux-create-reducer - 9 common examples

To help you get started, we’ve selected a few redux-create-reducer 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 arjun27 / rubberduck / src / content_script / reducers / dataReducer / index.ts View on Github external
import { createReducer } from "redux-create-reducer";
import { combineReducers } from "redux";
import section from "./section";
import { repoDetails, view } from "./repoDetails";
import fileTree from "./fileTree";
import definition from "./definition";
import usages from "./usages";
import hoverResult from "./hoverResult";
import session from "./session";
import fileContents from "./fileContents";
import pjax from "./pjax";

const initialState = {};

const data = createReducer(initialState, {
  UPDATE_DATA: (state, action: any) => ({
    ...state,
    ...action.payload
  })
});

const dataReducer = combineReducers({
  data,
  repoDetails, // old repo details (for backward compatibility)
  view, // new repo details
  section,
  session,
  fileTree,
  definition,
  usages,
  hoverResult,
github aigoncharov / reducer-class / src / reducer-class.ts View on Github external
public static create(this: (new () => IReducerClassConstraintComplete) & IReducerClassStatic): Reducer {
    const instance = new this()
    const keys = this.reducerClassHelpers.getClassInstanceMethodNames(instance)
    const reducersWithActionTypes = this.reducerClassHelpers.getReducerClassMethodsWthActionTypes(
      instance as IReducerClassConstraint,
      keys,
    )
    const reducerMap = this.reducerClassHelpers.getReducerMap(reducersWithActionTypes)
    // TODO: Remove as Handlers once https://github.com/kolodny/redux-create-reducer/pull/17 is merged
    return createReducer((instance as ReducerClass).initialState, reducerMap as Handlers)
  }
github ritz078 / snape / renderer / reducers / loading.js View on Github external
import { createReducer } from 'redux-create-reducer';

const loadingReducer = createReducer(false, {
  START_LOADING: () => true,
  STOP_LOADING: () => false,
});

export default loadingReducer;
github arjun27 / rubberduck / src / content_script / reducers / dataReducer / fileContents.ts View on Github external
import { createReducer } from "redux-create-reducer";

const initialState = {
  base: {},
  head: {}
};

export default createReducer(initialState, {
  CALL_FILE_CONTENTS_FULFILLED: (state, action: any) => {
    const { baseOrHead, filePath, result } = action.payload;
    let newState = { ...state };
    newState[baseOrHead][filePath] = result.contents;
    return newState;
  }
});
github JetBrains / youtrack-mobile / src / views / inbox / inbox-reducers.js View on Github external
import {createReducer} from 'redux-create-reducer';
import * as types from './inbox-action-types';

export type InboxState = {
  loading: boolean,
  items: Array,
  hasMore: boolean
};

const initialState: InboxState = {
  loading: false,
  hasMore: true,
  items: []
};

export default createReducer(initialState, {
  [types.SET_LOADING](state, {loading}): InboxState {
    return {...state, loading};
  },

  [types.ADD_ITEMS](state, {items, hasMore}): InboxState {
    return {...state, items: [...state.items, ...items], hasMore};
  },

  [types.RESET_ITEMS](state): InboxState {
    return {...state, items: [], hasMore: true};
  },

  [types.LIST_END_REACHED](state): InboxState {
    return {...state, hasMore: false};
  }
});
github JetBrains / youtrack-mobile / src / views / create-issue / create-issue-reducers.js View on Github external
const initialState: CreateIssueState = {
  processing: false,
  attachingImage: null,
  predefinedDraftId: null,

  issue: {
    summary: '',
    description: '',
    attachments: [],
    fields: [],
    project: notSelectedProject
  }
};

export default createReducer(initialState, {
  [LOG_OUT](state: CreateIssueState, action: {draftId: string}): CreateIssueState {
    return initialState;
  },
  [types.SET_ISSUE_PREDEFINED_DRAFT_ID](state: CreateIssueState, action: {draftId: string}): CreateIssueState {
    return {...state, predefinedDraftId: action.draftId};
  },
  [types.SET_ISSUE_DRAFT](state: CreateIssueState, action: {issue: IssueFull}): CreateIssueState {
    return {...state, issue: {...state.issue, ...action.issue}};
  },
  [types.RESET_ISSUE_DRAFT](state: CreateIssueState): CreateIssueState {
    return {
      ...state,
      issue: {
        ...state.issue,
        id: null
      }
github JetBrains / youtrack-mobile / src / views / issue-list / issue-list-reducers.js View on Github external
const initialState: IssuesListState = {
  query: '',
  queryAssistSuggestions: [],
  skip: 0,
  isLoadingMore: false,
  isListEndReached: false,

  loadingError: null,
  isInitialized: false,
  isRefreshing: false,
  issuesCount: null,
  issues: []
};

export default createReducer(initialState, {
  [LOG_OUT]: (state: IssuesListState): IssuesListState => {
    return initialState;
  },
  [ISSUE_CREATED]: (state: IssuesListState, action: {issue: IssueFull}): IssuesListState => {
    return {...state, issues: [action.issue, ...state.issues]};
  },
  [types.SET_ISSUES_QUERY]: (state: IssuesListState, action: Object) => {
    return {...state, query: action.query};
  },
  [types.SUGGEST_QUERY]: (state: IssuesListState, action: Object) => {
    return {...state, queryAssistSuggestions: action.suggestions};
  },
  [types.CLEAR_SUGGESTIONS]: (state: IssuesListState, action: Object) => {
    return {...state, queryAssistSuggestions: []};
  },
  [types.START_ISSUES_LOADING]: (state: IssuesListState, action: Object) => {
github istvanmakary / react-native-debugger / src / redux / module.js View on Github external
);

export const getDebugger = (state) => {
  if (!state.debugger) {
    return {};
  }

  return {
    ...state.debugger,
    events: state.debugger.events.filter((e) => (
      matchLogLevel(state, e.logType) && (state.debugger.debugTypes || []).includes(e.type)
    )).sort((a,b) => b.date - a.date),
  };
};

export default createReducer(initialState, {
  [INIT]: (state, { payload }) => ({
    ...state,
    ...payload,
  }),
  [DEBUG_EVENTS]: (state, { payload }) => ({
    ...state,
    events: [
      ...payload,
      ...state.events.slice(0, 200),
    ],
  }),
  [CLOSE]: (state) => ({
    ...state,
    isVisible: false,
  }),
  [SHOW]: (state) => ({
github JetBrains / youtrack-mobile / src / views / agile-board / board-reducers.js View on Github external
};

const initialPageState: AgilePageState = {
  isLoading: false,
  profile: null,
  noBoardSelected: false,
  isSprintSelectOpen: false,
  isOutOfDate: false,
  creatingIssueDraftId: null,
  creatingIssueDraftCellId: null,
  selectProps: null,
  sprint: null,
  serversideEvents: null
};

const boardReducer = createReducer({}, {
  [types.RECEIVE_SWIMLANES](state: BoardState, action: Object): BoardState {
    return {
      ...state,
      trimmedSwimlanes: [...state.trimmedSwimlanes, ...action.swimlanes]
    };
  },
  [types.ROW_COLLAPSE_TOGGLE](state: BoardState, action: {row: AgileBoardRow, newCollapsed: boolean}): BoardState {
    return updateRowCollapsedState(state, action.row, action.newCollapsed);
  },
  [types.COLUMN_COLLAPSE_TOGGLE](state: BoardState, action: Object): BoardState {
    return {
      ...state,
      columns: (state.columns || []).map(it => {
        return it === action.column ? {...action.column, collapsed: action.newCollapsed} : it;
      })
    };

redux-create-reducer

Publishing createReducer from https://redux.js.org/recipes/reducing-boilerplate#generating-reducers

MIT
Latest version published 4 years ago

Package Health Score

51 / 100
Full package analysis

Popular redux-create-reducer functions