How to use the redux-logic.createLogicMiddleware function in redux-logic

To help you get started, we’ve selected a few redux-logic 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 popcodeorg / popcode / src / createApplicationStore.js View on Github external
export default function createApplicationStore() {
  const sagaMiddleware = createSagaMiddleware({
    onError(error) {
      if (get(console, ['error'])) {
        // eslint-disable-next-line no-console
        console.error(error);
      }
      bugsnagClient.notify(error);
    },
  });
  const sagaEnhancer = applyMiddleware(sagaMiddleware);

  const logicMiddleware = createLogicMiddleware(rootLogic);
  const logicEnhancer = applyMiddleware(logicMiddleware);

  const store = createStore(reducers, compose(sagaEnhancer, logicEnhancer));
  sagaMiddleware.run(rootSaga);

  return store;
}
github jeffbski / redux-logic / examples / single-file-redux / src / index.js View on Github external
console.error(err); // might be a render err
        dispatch({
          type: USERS_FETCH_REJECTED,
          payload: err,
          error: true
        });
      })
      .then(() => done()); // call done when finished dispatching
  }
});

const deps = { // injected dependencies for logic
  httpClient: axios
};
const arrLogic = [usersFetchLogic];
const logicMiddleware = createLogicMiddleware(arrLogic, deps);
const store = createStore(reducer, initialState,
                          applyMiddleware(logicMiddleware));

const containerDiv = document.getElementById('container');
store.subscribe(() => {
  const state = store.getState();
  console.log('state fetchStatus:%o list:%o', state.fetchStatus, state.list);
  containerDiv.innerHTML += formatStateForHTML(state);
});

function formatStateForHTML(state) {
  return (
  `<div>
     <div>State at: ${Date.now()}</div>
     <div>fetchStatus: ${state.fetchStatus}</div>
     <ul></ul></div>
github jaganathanb / vilaippattiyal / src / app / store / configureStore.dev.js View on Github external
import rootReducer from '../reducers';
import rootActions from '../actions';

import logic from '../logics';

import api from '../../db';

const history = createHashHistory();

const deps = {
  // injected dependencies for logic
  Db: api.Db
};

const logicMiddleware = createLogicMiddleware(logic, deps);

const configureStore = initialState => {
  // Redux Configuration
  const middleware = [];
  const enhancers = [];

  // Thunk Middleware
  middleware.push(logicMiddleware);

  // Logging Middleware
  const logger = createLogger({
    level: 'info',
    collapsed: true
  });

  // Skip redux logs in console during the tests
github jeffbski / redux-logic / examples / async-rxjs-ajax-proc-options / src / configureStore.js View on Github external
import logic from './rootLogic';

import { ajax } from 'rxjs/ajax';

// selectively just getting ajax and map from rxjs to keep size smaller
// be sure to add everything you need in your logic
// import 'rxjs/Observable';
// import 'rxjs/add/operator/catch';
// import 'rxjs/add/operator/map';
// import { ajax } from 'rxjs/observable/dom/ajax';

const deps = { // injected dependencies for logic
  httpClient: ajax.getJSON // RxJS ajax
};

const logicMiddleware = createLogicMiddleware(logic, deps);

const middleware = applyMiddleware(
  logicMiddleware
);


// using compose to allow for applyMiddleware, just add it in
const enhancer = (typeof devToolsExtension !== 'undefined') ?
      compose(
        middleware,
        devToolsExtension()
      ) :
      middleware;

export default function configureStore() {
  const store = createStore(rootReducer, enhancer);
github TheThingsNetwork / lorawan-stack / pkg / webui / oauth / store / index.js View on Github external
export default function(history) {
  const middleware = applyMiddleware(routerMiddleware(history), createLogicMiddleware(logic))

  return createStore(connectRouter(history)(reducer), composeEnhancers(middleware))
}
github FreemapSlovakia / freemap-v3-react / src / middlewares / logicMiddleware.js View on Github external
import { createLogicMiddleware } from 'redux-logic';

const logicsCtx = require.context('fm3/logic', false, /Logic\.[tj]s$/);
const logics = []
  .concat(
    ...logicsCtx
      .keys()
      .sort()
      .map(k => logicsCtx(k).default),
  )
  .filter(m => m);

export const logicMiddleware = createLogicMiddleware(logics);
github kuy / lifegame-redux / src / logic-rx / store.js View on Github external
export default function configureStore(initialState) {
  const deps = {};
  const logicMiddleware = createLogicMiddleware(logics, deps);
  return createStore(
    reducer,
    initialState,
    applyMiddleware(
      logicMiddleware, logger()
    )
  );
};
github zhenyulin / ultimate-hot-boilerplate / client / store.js View on Github external
export default function setupStore(history) {
  const middleware = [
    routerMiddleware(history),
    createLogicMiddleware(logics),
    createTracker(),
  ];

  if (process.env.NODE_ENV === 'development') {
    const { composeWithDevTools } = require('redux-devtools-extension');
    const enhancer = composeWithDevTools(applyMiddleware(...middleware));
    const store = createStore(reducer, enhancer);

    if (module.hot) {
      module.hot.accept('./controllers/reducers', () => {
        const nextRootReducer = require('./controllers/reducers').default;
        store.replaceReducer(nextRootReducer);
      });
    }

    return store;
github tylerlong / hello-async / redux-logic / src / index.js View on Github external
import React from 'react'
import ReactDOM from 'react-dom'
import { createStore, applyMiddleware } from 'redux'
import { Provider } from 'react-redux'
import { createLogicMiddleware } from 'redux-logic'

import './index.css'
import App from './App'
import reducer from './reducers'
import logic from './logics'

const logicMiddleware = createLogicMiddleware(logic)

const store = createStore(
  reducer,
  applyMiddleware(logicMiddleware)
)

ReactDOM.render(
  
    
  ,
  document.getElementById('root')
)
github TheThingsNetwork / lorawan-stack / pkg / webui / console / store / index.js View on Github external
export default function(history) {
  const middleware = applyMiddleware(
    requestPromiseMiddleware,
    routerMiddleware(history),
    createLogicMiddleware(logics),
  )

  return createStore(connectRouter(history)(reducer), composeEnhancers(middleware))
}

redux-logic

Redux middleware for organizing all your business logic. Intercept actions and perform async processing.

MIT
Latest version published 1 year ago

Package Health Score

57 / 100
Full package analysis