How to use redux-immutablejs - 10 common examples

To help you get started, we’ve selected a few redux-immutablejs 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 YouYII / EasyReader / src / ducks / directory.js View on Github external
const fetchListSuccess = createAction(FETCH_LIST_SUCCESS);
const fetchListFailed = createAction(FETCH_LIST_FAILED);
export const updateListOrder = createAction(UPDATE_LIST_ORDER);
export const updateLastRead = createAction(UPDATE_LAST_READ);
// export const updateNovelStar = createAction(UPDATE_NOVEL_STAR);

const initialState = Immutable.fromJS({
  fetching:true,
  error:'',
  directory:[],
  directoryUrl:'',
  order:'asc',
  lastReadIndex:0,
});

export default createReducer(initialState,{
  [FETCH_LIST](state,action) {
    return state.merge({
      directoryUrl:action.payload,
      fetching:true,
      error:'',
      directory:[],
      order:'asc',
      lastReadIndex:0,
    });
  },
  [FETCH_LIST_SUCCESS](state,action) {
    if (action.payload.length>0 
      && action.payload.length == state.get('directory').size 
      && action.payload[action.payload.length-1].title == state.getIn(['directory',state.get('directory').size-1,'title'])
      ) {
      return state.merge({
github YouYII / EasyReader / src / ducks / routes.js View on Github external
import { ActionConst } from 'react-native-router-flux';
import { createReducer } from 'redux-immutablejs'
import Immutable from 'immutable'
const initialState = Immutable.fromJS({
  scene: {},
});

export default createReducer(initialState,{
  [ActionConst.FOCUS](state,{scene}) {
    return state.merge({
      scene,
    });
  },
  
});
github lynndylanhurley / redux-auth-demo / src / reducers / demo-ui.js View on Github external
import Immutable from 'immutable';
import { createReducer } from 'redux-immutablejs';
import * as A from '../actions/demo-ui';

const initialState = Immutable.fromJS({
  theme: 'materialUi',
  endpoint: 'default'
});

export default createReducer(initialState, {
  [A.UPDATE_DEMO_THEME]: (state, { theme }) => state.merge({ theme }),
  [A.UPDATE_DEMO_ENDPOINT]: (state, { endpoint }) => state.merge({ endpoint })
});
github researchstudio-sat / webofneeds / webofneeds / won-owner-webapp / src / main / webapp / app / reducers / match-reducer.js View on Github external
*/
import { actionTypes } from '../actions/actions';
import { repeatVar } from '../utils';
import Immutable from 'immutable';
import { createReducer } from 'redux-immutablejs'
import { combineReducersStable } from '../redux-utils';
import { buildCreateMessage } from '../won-message-utils';
import won from '../won-es6';

const initialState = Immutable.fromJS({
    isFetching: false,
    didInvalidate: false,
    matches: {}

})
export default createReducer(
    initialState,
    {
        [actionTypes.matches.add]:(state,action)=>{
            return state.setIn(['matches',action.payload.connection.uri],action.payload)
        }

    }

)
github researchstudio-sat / webofneeds / webofneeds / won-owner-webapp / src / main / webapp / app / reducers / requests-reducer.js View on Github external
import { actionTypes } from '../actions/actions';
import { repeatVar } from '../utils';
import Immutable from 'immutable';
import { createReducer } from 'redux-immutablejs'
import { combineReducersStable } from '../redux-utils';
import { buildCreateMessage } from '../won-message-utils';
import won from '../won-es6';

const initialState = Immutable.fromJS({
    isFetching: false,
    didInvalidate: false,
    incomingRequestsByNeed: {}

})
export default createReducer(
    initialState,
    {
        [actionTypes.requests.incomingReceived]:(state,action)=>{
            let byNeed = state.getIn(['incomingRequestsByNeed',action.payload.ownNeed['@id']])
            if(!byNeed){
                state.setIn(['incomingRequestsByNeed',action.payload.ownNeed['@id']],[action.payload])
            }else{

            }


            let match = {"ownNeedData":action.payload.ownNeed,"connections":action.payload.connections}
            return state.setIn(['matches',action.payload.connection.uri],action.payload)
        },
        [actionTypes.matches.add]:(state,action)=>{
            return state.setIn(['matches',action.payload.connection.uri],action.payload)
github jackhutu / jackblog-react / src / reducers / sns.js View on Github external
import { GET_SNSLOGINS_SUCCESS,GET_SNSLOGINS_FAILURE} from 'actions/types'
import { createReducer } from 'redux-immutablejs'
import {fromJS} from 'immutable'

export default createReducer(fromJS({
  logins:[]
}), {
  [GET_SNSLOGINS_FAILURE]: (state, action) => state.set('logins',[]),
  [GET_SNSLOGINS_SUCCESS]: (state,{json}) => state.set('logins',json.data)
})
github jackhutu / jackblog-react / src / reducers / article.js View on Github external
[ARTICLE_LIST_FAILURE]: (state,action)=>state.set('isFetching',false)
})

export const articleDetail = createReducer(fromJS({}),{
  [ARTICLE_DETAIL_SUCCESS]:(state,action)=>state.merge(action.articleDetail),
  [ARTICLE_DETAIL_FAILURE]:(state,action)=>state,
  [TOGGLE_LIKE_SUCCESS]:(state,action)=>{
    return state.merge({
      isLike:action.isLike, 
      like_count:action.like_count
    })
  },
  [TOGGLE_LIKE_FAILURE]:(state,action)=>state
})

export const prenextArticle = createReducer(fromJS({
  'next':{},'prev':{}
}),{
  [PRENEXT_ARTICLE_SUCCESS]:(state,{json})=>{
    return state.merge(json.data)
  },
  [PRENEXT_ARTICLE_FAILURE]:(state,{json})=>state
})
github jackhutu / jackblog-react / src / reducers / globalVal.js View on Github external
import { 
  CHANGE_STYLE_MODE,
  GET_INDEX_IMG_SUCCESS,
  GET_INDEX_IMG_FAILURE,
  GET_CAPTCHAURL
} from 'actions/types'
import { createReducer } from 'redux-immutablejs'
import { fromJS } from 'immutable'
import img from 'assets/images/shanghai.jpg'
import { API_ROOT } from '../config'
import { getCookie,saveCookie } from 'utils/authService'

export default createReducer(fromJS({
  indexImg:'',
  styleMode: getCookie('styleMode') || 'day-mode',
  captchaUrl: API_ROOT + 'users/getCaptcha?'
}), {
  [CHANGE_STYLE_MODE]: (state, action) => {
    let styleMode = state.get('styleMode') === 'day-mode'?'night-mode':'day-mode'
    saveCookie('styleMode', styleMode)
    return state.set('styleMode',styleMode)
  },
  [GET_CAPTCHAURL]: (state, action) => state.set('captchaUrl',action.captchaUrl),
  [GET_INDEX_IMG_SUCCESS]: (state, {json}) => state.set('indexImg',json.img),
  [GET_INDEX_IMG_FAILURE]: (state, {json}) => state.set('indexImg',img)
})
github jackhutu / jackblog-react / src / reducers / article.js View on Github external
items: []
})

export const articleList = createReducer(initialState,{
  [ARTICLE_LIST_REQUEST]: (state,action)=>state.set('isFetching',true),
  [ARTICLE_LIST_SUCCESS]: (state,action)=>{
    return state.merge({
      isFetching:false,
      isMore: !(action.json.data.length < action.itemsPerPage),
      items: action.isAdd?state.get('items').concat(action.json.data):action.json.data
    })
  },
  [ARTICLE_LIST_FAILURE]: (state,action)=>state.set('isFetching',false)
})

export const articleDetail = createReducer(fromJS({}),{
  [ARTICLE_DETAIL_SUCCESS]:(state,action)=>state.merge(action.articleDetail),
  [ARTICLE_DETAIL_FAILURE]:(state,action)=>state,
  [TOGGLE_LIKE_SUCCESS]:(state,action)=>{
    return state.merge({
      isLike:action.isLike, 
      like_count:action.like_count
    })
  },
  [TOGGLE_LIKE_FAILURE]:(state,action)=>state
})

export const prenextArticle = createReducer(fromJS({
  'next':{},'prev':{}
}),{
  [PRENEXT_ARTICLE_SUCCESS]:(state,{json})=>{
    return state.merge(json.data)
github lynndylanhurley / redux-auth / src / reducers / email-sign-in.js View on Github external
import Immutable from "immutable";
import { createReducer } from "redux-immutablejs";
import * as A from "../actions/email-sign-in";
import { SET_ENDPOINT_KEYS } from "../actions/configure";

const initialState = {
  loading: false,
  errors: null,
  form: {}
};

export default createReducer(Immutable.fromJS({}), {
  [SET_ENDPOINT_KEYS]: (state, {endpoints}) => state.merge(endpoints.reduce((coll, k) => {
    coll[k] = Immutable.fromJS(initialState);
    return coll;
  }, {})),

  [A.EMAIL_SIGN_IN_START]: (state, {endpoint}) => state.setIn([endpoint, "loading"], true),

  [A.EMAIL_SIGN_IN_COMPLETE]: (state, {endpoint}) => state.merge({[endpoint]: initialState}),

  [A.EMAIL_SIGN_IN_ERROR]: (state, {endpoint, errors}) => state.mergeDeep({
    [endpoint]: {
      loading: false,
      errors
    }
  }),

redux-immutablejs

Redux Immutable facilities

BSD-3-Clause
Latest version published 9 years ago

Package Health Score

48 / 100
Full package analysis

Popular redux-immutablejs functions

Similar packages