How to use redux-batched-subscribe - 10 common examples

To help you get started, we’ve selected a few redux-batched-subscribe 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 stackscz / re-app / src / utils / createStore.js View on Github external
];
	if (process.env.NODE_ENV !== 'production') {
		if (config.logging !== false) {
			middleware.push(require('redux-logger')());
		}
	}

	enhancers.unshift(applyMiddleware(...middleware));

	// use batched updates?
	let batchedSubscribeFunc = null;
	if (process.env.UNIVERSAL_ENV !== 'server') {
		const batchedSubscribe = require('redux-batched-subscribe').batchedSubscribe;
		// avoid dependency on react-dom on server
		const batchedUpdates = require('react-dom').unstable_batchedUpdates;
		batchedSubscribeFunc = batchedSubscribe(batchedUpdates);
	}

	const rootReducer = combineReducers(reducers);
	const store = compose(...enhancers)(reduxCreateStore)(
		rootReducer,
		initialState,
		batchedSubscribeFunc
	);
	store.dispatch(init());
	if (sagas.length) {
		sagas.forEach((saga) => runSaga(sagaMiddleware, saga));
	}
	return store;
}
github AuHau / daGui / app / core / shared / store / configureStore.production.js View on Github external
// @flow
import { createStore, compose } from 'redux';
import { batchedSubscribe } from 'redux-batched-subscribe';


import rootReducer from '../reducers';

const enhancers = compose(
  batchedSubscribe(fn => fn())
);

export default function configureStore(initialState: Object) {
  return createStore(rootReducer, initialState, enhancers);
}
github AuHau / daGui / app / core / shared / store / configureStore.development.js View on Github external
});


// If Redux DevTools Extension is installed use it, otherwise use Redux compose
/* eslint-disable no-underscore-dangle */
// const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
//   window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
//     // Options: http://zalmoxisus.github.io/redux-devtools-extension/API/Arguments.html
//     actionCreators,
//   }) :
//   compose;
/* eslint-enable no-underscore-dangle */
const enhancer = compose(
  applyMiddleware(logger, reduxMulti, thunk),
  window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__() : noop => noop,
  batchedSubscribe(notify => notify()),
  autoRehydrate()
);

export default function configureStore(initialState: Object) {
  const store = createStore(rootReducer, initialState, enhancer);

  if (module.hot) {
    module.hot.accept('../reducers', () =>
      store.replaceReducer(require('../reducers')) // eslint-disable-line global-require
    );
  }

  persistStore(store, {
    storage: localForage,
    blacklist: ['ui'],
    transforms: [functionSerialize],
github ShieldBattery / ShieldBattery / client / create-store.js View on Github external
export default function create(initialState, history) {
  const createMiddlewaredStore = compose(
    applyMiddleware(thunk, promise, routerMiddleware(history)),
    batchedSubscribe(batchedUpdates),
    // Support for https://github.com/zalmoxisus/redux-devtools-extension
    isDev && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__() : f => f,
  )(createStore)

  const store = createMiddlewaredStore(createRootReducer(history), initialState)

  return store
}
github threepointone / redux-react-local / example / root.js View on Github external
initial || {},

    // middleware
    compose(
      applyMiddleware(...(function *() {
        yield* middleware
        yield sagaMiddleware
        if (process.env.NODE_ENV === 'development') {
          yield ensureFSA
        }
      }())),
      typeof window === 'object' &&
      typeof window.devToolsExtension !== 'undefined' &&
      process.env.NODE_ENV === 'development'
        ? window.devToolsExtension() : f => f,
      batchedSubscribe(process.env.RAF === true ?
        rafUpdateBatcher : unstable_batchedUpdates))
  )

  store.sagas = sagaMiddleware
  return store
}
github amrav / sparrow / ui / src / redux / configureStore.js View on Github external
export default function configureStore (initialState) {
    console.log(rootReducer);
    const store = createStore(rootReducer, initialState, compose(
        applyMiddleware(thunk),
        window.devToolsExtension ? window.devToolsExtension() : f => f,
        batchedSubscribe(batchedUpdates)
    ));

    if (module.onReload) {
        module.onReload(() => {
            const nextReducer = require('../reducers');
            store.replaceReducer(nextReducer.default || nextReducer);
            return true;
        });
    }
    return store;
}
github amsul / react-performance / lib / createNotifier.js View on Github external
const createNotifier = () => {
  let notifyAnimationFrame = null
  return batchedSubscribe(debounce({ wait: 5, method: (notify) => {
    if (notifyAnimationFrame) {
      return
    }
    notifyAnimationFrame = requestAnimationFrame(() => {
      notifyAnimationFrame = null
      console.group('Notifying store updates')
      console.time('Store update render time')
      notify()
      console.timeEnd('Store update render time')
      console.groupEnd()
    })
  }}))
}
github lore / lore / packages / lore-redux / src / getStore.js View on Github external
/**
   * Enhance the store with third-party capabilities such as middleware,
   * time travel, persistence, etc.
   *
   * If DevTools are provided, enhance the Redux Store with instrumentation support.
   *
   * http://redux.js.org/docs/api/compose.html
   */

  const enhancer = DevTools ? (
    compose(
      applyMiddleware(...middleware),
      DevTools.instrument(),
      batchedSubscribe(_.debounce(function(notify) {
        notify();
      }, debounceWait))
    )
  ) : (
    compose(
      applyMiddleware(...middleware),
      batchedSubscribe(_.debounce(function(notify) {
        notify();
      }, debounceWait))
    )
  );


  /**
   * Combine all reducers into a single reducer function, which will be used
   * by the Redux store. If there are no reducers, returns an empty function
github lore / lore / packages / lore-cli-new / templates / lore / redux.js View on Github external
/**
   * Enhance the store with third-party capabilities such as middleware,
   * time travel, persistence, etc.
   *
   * If DevTools are provided, enhance the Redux Store with instrumentation support.
   *
   * http://redux.js.org/docs/api/compose.html
   */

  const enhancer = DevTools ? (
    compose(
      applyMiddleware(...middleware),
      DevTools.instrument(),
      batchedSubscribe(_.debounce(function(notify) {
        notify();
      }, debounceWait))
    )
  ) : (
    compose(
      applyMiddleware(...middleware),
      batchedSubscribe(_.debounce(function(notify) {
        notify();
      }, debounceWait))
    )
  );


  /**
   * Combine all reducers into a single reducer function, which will be used
   * by the Redux store. If there are no reducers, returns an empty function
github lore / lore / packages / lore-hook-redux / src / index.js View on Github external
enhancer: function(middleware, config) {
        return compose(
          applyMiddleware.apply(null, middleware),
          batchedSubscribe(_.debounce(function(notify) {
            notify();
          }, config.redux.debounceWait))
        );
      },

redux-batched-subscribe

redux store enhancer which allows batching subscribe notifications.

MIT
Latest version published 9 years ago

Package Health Score

50 / 100
Full package analysis

Popular redux-batched-subscribe functions