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


TypeScript redux-logger類代碼示例

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


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

示例1: configureStore

/// <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

示例2: 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

示例3: 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

示例4: createLogger

import { flushMicrotasks } from '@angular/core/testing';

import { Iterable } from 'immutable';

import * as createLogger from 'redux-logger';

export const logger = createLogger({
  level: 'debug',
  collapsed: true,
  predicate: (getState, action) => true,
  stateTransformer:
    state => {
      const newState = new Object();

      for (const i of Object.keys(state)) {
        newState[i] = Iterable.isIterable(state[i])
          ? state[i].toJS()
          : state[i];
      };

      return newState;
    }
  });

export const simulateUserTyping = (control, text: string): Promise<void> => {
  return new Promise<void>((resolve, reject) => {
    try {
      dispatchKeyEvents(control, text);
      resolve();
    } catch (error) {
      console.error('Failed to dispatch typing events', error);
開發者ID:danielfigueiredo,項目名稱:ng2-redux-form,代碼行數:31,代碼來源:tests.utilities.ts

示例5: createStoreWithMiddleware

/// <reference path="../interfaces/interfaces.d.ts" />

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

import reducer from '../reducers/rootReducer';

const logger = createLogger();

const createStoreWithMiddleware = applyMiddleware(
    thunk,
    logger
)(createStore);

export default function configureStore(initialState) {
    return createStoreWithMiddleware(reducer, initialState);
}
開發者ID:LBL-Sample,項目名稱:React-Redux-Typescript,代碼行數:18,代碼來源:configureStore.ts

示例6: routerMiddleware

import thunk from 'redux-thunk';
import DevTools from '../containers/devTools';
import { rootReducer } from '../reducers';
import { hashHistory } from 'react-router';
import { persistState } from 'redux-devtools';
import { routerMiddleware } from 'react-router-redux';
import { createStore, applyMiddleware, compose } from 'redux';
import * as createLogger from 'redux-logger';
import { initialState } from './props';
const router = routerMiddleware(hashHistory);
// create logger
const logger = createLogger({
    level: 'info',
    collapsed: true,
});

const enhancer = compose(
    applyMiddleware(thunk, router, logger),
    DevTools.instrument(),
    persistState(
        window.location.href.match(
            /[?&]debug_session=([^&]+)\b/
        ))
)

export const store = createStore(rootReducer, initialState, applyMiddleware(thunk));
開發者ID:thehachez,項目名稱:maduk,代碼行數:26,代碼來源:store.ts

示例7: createLogger

import * as createLogger from 'redux-logger'

const logger = createLogger({
  collapsed: true,
  stateTransformer: (state) => {
    // return immutableToJS(state);
    return state
  },
  predicate: (getState, action) => {
    const type = action.type
    return type !== 'redux-form/BLUR' &&
      type !== 'redux-form/CHANGE' &&
      type !== 'redux-form/FOCUS' &&
      type !== 'redux-form/TOUCH'
  },
});


export default logger;
開發者ID:tiengtinh,項目名稱:react-redux-saga-typescript-starter-kit,代碼行數:19,代碼來源:logger.ts

示例8: createLogger

/// <reference path="./redux-logger.d.ts" />

import * as createLogger from 'redux-logger';
import { applyMiddleware, createStore } from 'redux'

let logger = createLogger();

let loggerSimpleOpts = createLogger({
  duration: true,
  timestamp: true,
  logger: console,
  logErrors: true,
  predicate: (getState, action) => true,
  stateTransformer: (state) => state,
  actionTransformer: (action) => action,
  errorTransformer: (error) => error,
  diff: true,
  diffPredicate: (getState, action) => true,
});

let loggerCollapsedBool = createLogger({
  collapsed: true
});

let loggerCollapsedPredicate = createLogger({
  collapsed: (getAction, action) => true
});

let loggerColorsBoolean = createLogger({
  colors: {
    title: false,
開發者ID:1drop,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:redux-logger-tests.ts

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: _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

示例14: 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

示例15: 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


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