How to use redux-immutable-state-invariant - 10 common examples

To help you get started, we’ve selected a few redux-immutable-state-invariant 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 pkellner / pluralsight-course-react-aspnet-core / m6-add-rest-data-to-server-side-rendering / reactapp / redux / configureStore.js View on Github external
if (!production) {
    require('dotenv').config();
}

const restUrl = production ?
    process.env.PROD_RESTURL :
    process.env.JSONSERVER_RESTURL;

let middleware = [
    thunk,
    axiosMiddleware(axios.create({baseURL:restUrl}))
];

if (!production) {
    middleware.push(require('redux-immutable-state-invariant').default());
    console.log('added redux-immutable-state-invariant');
}

export default function configureStore(initialState = {}) {

    const composeEnhancers = composeWithDevTools({
        // Specify name here, actionsBlacklist, actionsCreators and other options if needed
    });

    //const restUrl = 'http://localhost:4000/rest';
    //console.log('configureStore: ' + restUrl);
    const client = axios.create({ //all axios can be used, shown in axios documentation
        baseURL: restUrl,
        //responseType: 'json'
    });
github pkellner / pluralsight-course-react-aspnet-core / Progressions / m5-rest-calls / 12-Adding-Middleware / reactapp / redux / configureStore.js View on Github external
if (!production) {
    require('dotenv').config();
}

const restUrl = production ?
    process.env.PROD_RESTURL :
    process.env.JSONSERVER_RESTURL;

let middleware = [
    thunk,
    axiosMiddleware(axios.create({baseURL:restUrl}))
];

if (!production) {
    middleware.push(require('redux-immutable-state-invariant').default());
    console.log('added redux-immutable-state-invariant');
}

export default function configureStore(initialState = {}) {

    const composeEnhancers = composeWithDevTools({
        // Specify name here, actionsBlacklist, actionsCreators and other options if needed
    });

    //const restUrl = 'http://localhost:4000/rest';

    const client = axios.create({ //all axios can be used, shown in axios documentation
        baseURL: restUrl,
        //responseType: 'json'
    });
github zanata / zanata-platform / server / zanata-frontend / src / app / jsf / index.js View on Github external
import {
  toggleMTMergeModal,
  toggleTMMergeModal
} from '../actions/version-actions'
import {
  showExportTMXModal
} from '../actions/tmx-actions'

const DEV = process.env && process.env.NODE_ENV === 'development'

const logger = createLogger({
  // options
})

const middleware = [
  DEV && require('redux-immutable-state-invariant').default(),
  thunk,
  apiMiddleware,
  // routerMiddleware,
  DEV && logger // must be last to avoid logging thunk/promise
].filter(Boolean)

const finalCreateStore = compose(
  applyMiddleware(...middleware)
)(createStore)

// Call and assign the store with no initial state
const store = ((initialState) => {
  const store = finalCreateStore(rootReducer, initialState)
  if (module.hot) {
    // Enable Webpack hot module replacement for reducers
    module.hot.accept('../reducers', () => {
github zanata / zanata-platform / server / zanata-frontend / src / app / entrypoint / index.js View on Github external
'Source Code Pro:400,600'
    ]
  },
  timeout: 2000
})

const DEV = process.env && process.env.NODE_ENV === 'development'

// const routerMiddleware = syncHistory(history)

const logger = createLogger({
  // options
})

const middleware = [
  DEV && require('redux-immutable-state-invariant').default(),
  thunk,
  apiMiddleware,
  // routerMiddleware,
  DEV && logger // must be last to avoid logging thunk/promise
].filter(Boolean)

const finalCreateStore = compose(
  applyMiddleware(...middleware)
)(createStore)

// Call and assign the store with no initial state
const store = ((initialState) => {
  const store = finalCreateStore(rootReducer, initialState)
  // @ts-ignore module.hot
  if (module.hot) {
    // Enable Webpack hot module replacement for reducers
github zanata / zanata-platform / server / zanata-frontend / src / app / editor / middlewares / index.js View on Github external
actionTransformer: (action) => {
    return {
      ...action,
      // allow symbol action type to be printed properly in logs
      // TODO remove when types are migrated to stop using symbol
      type: String(action.type)
    }
  }
})

const middleware = [
  // TODO check if react helmet works here instead
  titleUpdateMiddleware,
  newContextFetchMiddleware,
  // reduxRouterMiddleware,
  DEV && require('redux-immutable-state-invariant').default(),
  thunk,
  enhancedCallApi,
  apiMiddleware,
  // must run after thunk because it fails with thunks
  getStateInActions,
  DEV && logger // must be last to avoid logging thunk/promise
].filter(Boolean)

const createStoreWithMiddleware = applyMiddleware(...middleware)(createStore)

export default createStoreWithMiddleware
github dexteryy / Project-WebCube / packages / redux-cube / src / core / appState.js View on Github external
import thunkPayloadMiddleware from '../middlewares/thunkPayload';
import { combineReducersWith } from '../utils';

let isProdEnv = true;
try {
  if (process.env.NODE_ENV !== 'production') {
    isProdEnv = false;
  }
} catch (ex) {}
const isSsrEnv = typeof location !== 'object';
const isDevToolsDisabled = isProdEnv || isSsrEnv;
let freezeMiddleware, logger, createLogger;
/* eslint-disable no-undef */
if (!isDevToolsDisabled) {
  // https://github.com/leoasis/redux-immutable-state-invariant
  freezeMiddleware = require('redux-immutable-state-invariant').default();
  // https://www.npmjs.com/package/redux-logger
  const reduxLogger = require('redux-logger');
  logger = reduxLogger.default;
  ({ createLogger } = reduxLogger);
}
/* eslint-enable no-undef */

export default function appState({
  // https://redux.js.org/docs/recipes/reducers/UsingCombineReducers.html
  // https://redux.js.org/docs/recipes/reducers/ReusingReducerLogic.html
  reducers,
  // optional
  // https://redux-observable.js.org/docs/basics/Epics.html
  epics = [],
  // optional
  disableDevTools = false,
github TrueCar / gluestick / packages / gluestick / shared / lib / createStore.js View on Github external
thunkMiddleware: Function,
  enhancers: Array = [],
): Store {
  const reducers = Object.assign({}, { _gluestick }, customRequire());
  const reducer: Object = combineReducers(reducers);

  let middleware: Function[] = [
    promiseMiddleware(client),
    // Using OR operator instead of default argument, since null value will be casted to false
    thunkMiddleware || thunk,
  ];

  // Include middleware that will warn when you mutate the state object
  // but only include it in dev mode
  if (devMode) {
    middleware.push(require('redux-immutable-state-invariant').default());
  }

  // When `customMiddleware` is of type `function`, pass it current
  // array of `middlewares` and expect a new value in return.
  // Fallback to default behaviour.
  middleware =
    typeof customMiddleware === 'function'
      ? customMiddleware([...middleware])
      : middleware.concat(customMiddleware);

  const composeArgs: Function[] = [
    applyMiddleware.apply(this, middleware),
    ...enhancers,
    typeof window === 'object' &&
    typeof window.devToolsExtension !== 'undefined' &&
    process.env.NODE_ENV !== 'production'
github origen-chat / api / projects / web / src / store / store.ts View on Github external
function getDevMiddleware(): ReadonlyArray {
  /* eslint-disable global-require */
  const { createLogger: createLoggerMiddleware } = require('redux-logger');
  const {
    default: createImmutableStateInvariantMiddleware,
  } = require('redux-immutable-state-invariant');
  /* eslint-enable global-require */

  const immutableStateInvariantMiddleware = createImmutableStateInvariantMiddleware();
  const loggerMiddleware = createLoggerMiddleware();

  const middleware = [immutableStateInvariantMiddleware, loggerMiddleware];

  return middleware;
}
github diescake / igata / src / app / store / index.ts View on Github external
const createReduxImmutableStateInvariant = () =>
  // eslint-disable-next-line
  process.env.NODE_ENV !== 'production' ? require('redux-immutable-state-invariant').default() : null
github batusai513 / next-saga-boilerplate / store / index.js View on Github external
function configureStoreDev(initialState) {
  const createLogger = require('redux-logger').createLogger;
  const loggerMiddleware = createLogger({
    collapsed: (getState, action) => typeof action === 'function',
    duration: true,
  });
  const middlewares = [
    // Add other middleware on this line...

    // Redux middleware that spits an error on you when you try to mutate your state either inside a dispatch or between dispatches.
    sagaMiddleware,
    require('redux-immutable-state-invariant').default(),
    loggerMiddleware,
    // thunk middleware can also accept an extra argument to be passed to each thunk action
    // https://github.com/gaearon/redux-thunk#injecting-a-custom-argument
    // thunk,
  ];

  const composeEnhancers = /*window !== undefined ? (window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose) :*/ compose;
  const store = createStore(
    rootReducer,
    initialState,
    composeEnhancers(applyMiddleware(...middlewares)),
  );

  if (module.hot) {
    // Enable Webpack hot module replacement for reducers
    module.hot.accept('../reducers', () => {

redux-immutable-state-invariant

Redux middleware that detects mutations between and outside redux dispatches. For development use only.

MIT
Latest version published 7 years ago

Package Health Score

53 / 100
Full package analysis

Popular redux-immutable-state-invariant functions

Similar packages