當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript redux-logger.default方法代碼示例

本文整理匯總了TypeScript中redux-logger.default方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript redux-logger.default方法的具體用法?TypeScript redux-logger.default怎麽用?TypeScript redux-logger.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在redux-logger的用法示例。


在下文中一共展示了redux-logger.default方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: configureStore

/*
 * @param {Object} initial state to bootstrap our stores with for server-side rendering
 * @param {History Object} a history object. We use `createMemoryHistory` for server-side rendering,
 *                          while using browserHistory for client-side
 *                          rendering.
 */
export default function configureStore(initialState, history) {
  let middleware = [ thunk, promiseMiddleware ];
  // Installs hooks that always keep react-router and redux
  // store in sync
  const reactRouterReduxMiddleware = routerMiddleware(history);
  if (__DEV__) {
    middleware.push(reactRouterReduxMiddleware, createLogger());
  } else {
    middleware.push(reactRouterReduxMiddleware);
  }

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

  const store = finalCreateStore(rootReducer, initialState);

  if ((module as any).hot) {
    // Enable Webpack hot module replacement for reducers
    (module as any).hot.accept('reducers', () => {
      const nextReducer = require('reducers');
      store.replaceReducer(nextReducer);
    });
  }

  return store;
}
開發者ID:eddieLiu69,項目名稱:react-webpack-node-tmpl,代碼行數:31,代碼來源:configureStore.ts

示例2: default

export default () => {
    const logger = createLogger({
        collapsed: true,
        level: 'info',
        duration: true
    })
    return createStore(rootReducer, applyMiddleware(thunk.default, logger))
}
開發者ID:sphingu,項目名稱:SPLClient,代碼行數:8,代碼來源:index.ts

示例3: _createStore

// chartId is only used for memoization.
function _createStore(chartId?: ChartId) {
  let middlewares: Redux.Middleware[] = [
    createDebounced(),
    ThunkMiddleware
  ];

  if (process.env.NODE_ENV === 'development') {
    middlewares.push(createLogger({
      actionTransformer: (action) => _.defaults({
        type: ActionType[ action.type ] || action.type
      }, action),
      collapsed: true
    }));
  }

  return applyMiddleware(...middlewares)(createStore)(reducer);
}
開發者ID:abe732,項目名稱:react-layered-chart,代碼行數:18,代碼來源:storeFactory.ts

示例4: configureStore

 export function configureStore(initialState:IAppState) {
     debugger
     const store = createStore(
         reducers, 
         initialState,
         compose(applyMiddleware(
             thunk,
             createLogger()
         ), DevTools.instrument())
     );
     
     if (module.hot) {
         module.hot.accept('../../src/reducers', () => {
             const nextRootReducer:Reducer = require('../../src/reducers/index.ts')['default'];
             store.replaceReducer(nextRootReducer);
         })
     }
     return store;
 }
開發者ID:pacjin79,項目名稱:typescript-playground,代碼行數:19,代碼來源:dev.ts

示例5: configureStore

export default function configureStore(preloadedState): Redux.Store {

  const store = createStore(
    rootReducer,
    preloadedState,
    compose(
      applyMiddleware(thunk, createLogger() ),
      applyMiddleware(routerMiddleware(hashHistory)),
      typeof window === 'object' && typeof window.devToolsExtension !== 'undefined' ? window.devToolsExtension() : f => f
    )
  );

  if (module.hot) {
    // Enable Webpack hot module replacement for reducers
    module.hot.accept('../reducers.ts', () => {
      const nextRootReducer = require('../reducers.ts').default;
      store.replaceReducer(nextRootReducer);
    });
  }
  return store;
}
開發者ID:zapkub,項目名稱:CheerUp-Thailand,代碼行數:21,代碼來源:store.dev.config.ts

示例6: createLogger

/// <reference path="../../typings/index.d.ts" />

import {applyMiddleware, createStore} from "redux";
import * as createLogger from "redux-logger";
import * as thunkMiddleware from "redux-thunk";
import * as reducers from "../reducers";

const loggerMiddleware: Redux.Middleware = createLogger();

export function configureStore(): Redux.Store<{}> {
  let store = createStore(reducers.rootReducer, {}, applyMiddleware(thunkMiddleware.default, loggerMiddleware));
  if (module.hot) {
    module.hot.accept("../reducers", () => {
      // tslint:disable-next-line:no-require-imports
      const nextRootreducer = require("../reducers").rootReducer;
      store.replaceReducer(nextRootreducer);
    });
  }
  return store;
}
開發者ID:fuyuno,項目名稱:Middleman-template,代碼行數:20,代碼來源:configureStore.ts

示例7: createLogger

const configureStore = ({reducer, devMode, throttle}) => {

  const middlewares = [thunk];

  // use logger if devMode
  if (devMode) {
    const logger = createLogger();
    middlewares.push(logger);
  } else {
    process.env.NODE_ENV = 'production';
  }

  // throttle save
  if (throttle) {
    const toThrottle = Object.keys(throttle);
    toThrottle.forEach((action: string) => {
        middlewares.push(
          throttleActions([].concat(action), throttle[action])
        );
    });
  }

  // create store with middlewares
  const store: Redux.Store = createStore(
    reducer,
    applyMiddleware(...middlewares)
  );

  return store;
};
開發者ID:coderoad,項目名稱:builder-coderoad,代碼行數:30,代碼來源:configureStore.ts

示例8: constructor

  constructor(
    private ngRedux: NgRedux<IAppState>,
    private devTool: DevToolsExtension) {

    this.ngRedux.configureStore(
      rootReducer,
      {},
      [ createLogger() ],
      [ ...enhancers, devTool.isEnabled() ? devTool.enhancer() : f => f]);
  }
開發者ID:veanyee,項目名稱:store,代碼行數:10,代碼來源:app.component.ts

示例9: applyMiddleware

import { createStore as createReduxStore, applyMiddleware } from "redux";
import thunk from "redux-thunk";
import * as createLogger from "redux-logger";

export const createStore = process.env.NODE_ENV === "development"
    ? applyMiddleware(thunk, createLogger({ collapsed: true }))(createReduxStore)
    : applyMiddleware(thunk)(createReduxStore);
開發者ID:CarlosWang,項目名稱:react-redux-typescript-start,代碼行數:7,代碼來源:createStore.ts

示例10: configureStore

import { createStore, applyMiddleware, compose } from 'redux';
import rootReducer from '../reducers/index';
import * as createLogger from 'redux-logger';
import thunk from 'redux-thunk';
import promiseMiddleware from 'redux-promise-middleware';
import { DevTools } from '../containers/DevTools.js';

const logger: any = createLogger();
/**
 * thunk, logger, promiseMiddleware are used as redux middleware
 *
 * uncomment logger to receive debug information in browser console
 */
const finalCreateStore = compose(
    applyMiddleware(logger, thunk, promiseMiddleware()),
    DevTools.instrument()
)(createStore);

export function configureStore(initialState) {
    return finalCreateStore(rootReducer, initialState);
};
開發者ID:malaman,項目名稱:other,代碼行數:21,代碼來源:configureStore.ts


注:本文中的redux-logger.default方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。