How to use reduxsauce - 10 common examples

To help you get started, we’ve selected a few reduxsauce 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 theqdev / react-big-bang / src / Redux / Posts.js View on Github external
// request the data from an api
export const get = (state, { data }) =>
  state.merge({ fetching: true, data })

// successful api lookup
export const success = (state, { data }) =>
  state.merge({ fetching: false, error: null, data:data })

// Something went wrong somewhere.
export const failure = state =>
  state.merge({ fetching: false, error: true })

/* ------------- Hookup Reducers To Types ------------- */

export const Posts = createReducer(INITIAL_STATE, {
  [Types.POSTS_GET]: get,
  [Types.POSTS_SUCCESS]: success,
  [Types.POSTS_FAILURE]: failure,
})
github infinitered / ignite / packages / ignite-infinite-red-app-template / templates / App / Redux / SearchRedux.js View on Github external
searching: false,
  results: LIST_DATA
})

/* ------------- Reducers ------------- */

export const performSearch = (state, { searchTerm }) => {
  const results = filter(startsWith(searchTerm), LIST_DATA)
  return state.merge({ searching: true, searchTerm, results })
}

export const cancelSearch = (state) => INITIAL_STATE

/* ------------- Hookup Reducers To Types ------------- */

export const reducer = createReducer(INITIAL_STATE, {
  [Types.SEARCH]: performSearch,
  [Types.CANCEL_SEARCH]: cancelSearch
})
github oktadeveloper / okta-react-native-spring-boot-example / react-native-app / App / modules / entities / blood-pressure / blood-pressure.reducer.js View on Github external
bloodPressure: state.bloodPressure
  })
}
// Something went wrong searching the entities.
export const searchFailure = (state, action) => {
  const { error } = action
  return state.merge({
    searching: false,
    errorSearching: error,
    bloodPressures: null
  })
}

/* ------------- Hookup Reducers To Types ------------- */

export const reducer = createReducer(INITIAL_STATE, {
  [Types.BLOOD_PRESSURE_REQUEST]: request,
  [Types.BLOOD_PRESSURE_ALL_REQUEST]: allRequest,
  [Types.BLOOD_PRESSURE_UPDATE_REQUEST]: updateRequest,
  [Types.BLOOD_PRESSURE_SEARCH_REQUEST]: searchRequest,
  [Types.BLOOD_PRESSURE_DELETE_REQUEST]: deleteRequest,

  [Types.BLOOD_PRESSURE_SUCCESS]: success,
  [Types.BLOOD_PRESSURE_ALL_SUCCESS]: allSuccess,
  [Types.BLOOD_PRESSURE_UPDATE_SUCCESS]: updateSuccess,
  [Types.BLOOD_PRESSURE_SEARCH_SUCCESS]: searchSuccess,
  [Types.BLOOD_PRESSURE_DELETE_SUCCESS]: deleteSuccess,

  [Types.BLOOD_PRESSURE_FAILURE]: failure,
  [Types.BLOOD_PRESSURE_ALL_FAILURE]: allFailure,
  [Types.BLOOD_PRESSURE_UPDATE_FAILURE]: updateFailure,
  [Types.BLOOD_PRESSURE_SEARCH_FAILURE]: searchFailure,
github TobiahRex / reactBoilerplate / src / redux / thing / index.js View on Github external
const getAllThingsSuccess = (state, { things }) => things || [];

const createThingSuccess = (state, { thing }) => state.concat(thing);

const editThingSuccess = (state, { thing }) => {
  const newState = state.slice();
  const index = state.findIndex(stateThing => stateThing._id === thing._id);
  newState[index] = thing;
  return newState;
};

const removeThingSuccess = (state, { thing }) =>
state.filter(stateThing => stateThing._id !== thing._id);

// ------- create Reducer ------- //
export const thingReducer = createReducer(INITIAL_STATE, {
  [Types.GET_ALL_THINGS_SUCCESS]: getAllThingsSuccess,
  [Types.EDIT_THING_SUCCESS]: editThingSuccess,
  [Types.REMOVE_THING_SUCCESS]: removeThingSuccess,
  [Types.CREATE_THING_SUCCESS]: createThingSuccess,
});
github AlexStack / Laravel-CMS / src / resources / reactJs / reduxStores / reducers / allPageReducers.js View on Github external
};
};

const setFilterKey = (state = INITIAL_STATE, action) => {
  return { ...state, filterKey: action.value };
};

// map our action types to our reducer functions
export const HANDLERS = {
  [actionTypes.LIST_ALL_PAGE_SUCCESS]: listAllPages,
  [actionTypes.DELETE_PAGE_SUCCESS]: deletePage,
  [actionTypes.SET_FILTER_KEY_SUCCESS]: setFilterKey
  // [actionTypes.APPLY_TASK_GROUP_FAILURE]: applyTaskFailure
};

export default createReducer(INITIAL_STATE, HANDLERS);
github easemob / webim-react-native / App / Redux / MessageRedux.js View on Github external
* @param state
 * @param message object
 * @param status enum [sending, sent ,fail]
 * @returns {*}
 */
export const updateMessageStatus = (state, {message, status = ''}) => {
  const {id} = message

  return state
    .setIn(['byId', id, 'status'], status)
    .setIn(['byId', id, 'time'], +new Date())
}

/* ------------- Hookup Reducers To Types ------------- */

export const reducer = createReducer(INITIAL_STATE, {
  [Types.ADD_MESSAGE]: addMessage,
  [Types.UPDATE_MESSAGE_STATUS]: updateMessageStatus,
})

/* ------------- Selectors ------------- */
github textileio / photos / App / Redux / IpfsNodeRedux.js View on Github external
return state.merge({...state, threads: newThreads})
}

export const photoHashesFailure = (state, {thread, error}) => {
  const currentThreadState = state.threads[thread]
  const newThreadState = currentThreadState.merge({querying: false, error})
  const newThreads = state.threads.set(thread, newThreadState)
  return state.merge({...state, threads: newThreads})
}

// Helper so sagas can figure out current items loaded
// const getItems = state => state.items

/* ------------- Hookup Reducers To Types ------------- */

export const reducer = createReducer(INITIAL_STATE, {
  [Types.LOCK]: lock,
  [Types.APP_STATE_CHANGE]: newAppState,
  [Types.CREATE_NODE_REQUEST]: creatingNode,
  [Types.CREATE_NODE_SUCCESS]: nodeCreated,
  [Types.CREATE_NODE_FAILURE]: nodeError,

  [Types.START_NODE_REQUEST]: nodeStarting,
  [Types.START_NODE_SUCCESS]: nodeStarted,
  [Types.START_NODE_FAILURE]: nodeError,

  [Types.STOP_NODE_REQUEST]: nodeStopping,
  [Types.STOP_NODE_SUCCESS]: nodeStopped,
  [Types.STOP_NODE_FAILURE]: nodeError,

  [Types.NODE_ONLINE]: nodeOnline,
github mollyywang / reactjs-redux-saga / src / reducers / index.js View on Github external
import { resettableReducer } from 'reduxsauce'
import { UserReducer } from '../features/User'
import { StarReducer } from '../features/Star'
import { SearchReducer } from '../features/Search'
import { ProductlistReducer } from '../features/Productlist'

const resettable = resettableReducer('RESET')
// combine all the reducers
const rootReducers = {
  user: resettable(UserReducer),
  star: resettable(StarReducer),
  search: SearchReducer,
  productlist: ProductlistReducer,
}
export default rootReducers
github Twotalltotems / react-native-paginatable / src / Components / PaginatableList / PaginationStateManager.js View on Github external
linkToReduxStore = () => {
        if (__DEV__) console.tron.log(`Link Reducer '${this.name}' to Redux Store. Use '${this.name}' as path of state subscription in Reactotron.`)
        injectAsyncReducer(reduxStore, this.name, createReducer(this.initialState, this.actionHandlers))
    }
github Twotalltotems / react-native-paginatable / PaginationStateManager.js View on Github external
addAction({ type, payload, handler }) {
		let handlerName = type
			.split(/(?=[A-Z])/)
			.join('_')
			.toUpperCase()

		this.actionObject[type] = payload
		const { Types, Creators } = createActions(this.actionObject, {
			prefix: `${this.name.toUpperCase()}_`
		})

		this.actionTypes = Types
		this.actions = Creators

		this.actionHandlers[Types[handlerName]] = handler

		Object.getPrototypeOf(this)[type] = args => {
			return dispatch => {
				dispatch(this.actions[type].apply(null, Object.values(args)))
			}
		}
	}

reduxsauce

Some aesthetic toppings for your Redux meal.

MIT
Latest version published 12 months ago

Package Health Score

67 / 100
Full package analysis