本文整理匯總了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;
}
示例2: default
export default () => {
const logger = createLogger({
collapsed: true,
level: 'info',
duration: true
})
return createStore(rootReducer, applyMiddleware(thunk.default, logger))
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
};
示例8: constructor
constructor(
private ngRedux: NgRedux<IAppState>,
private devTool: DevToolsExtension) {
this.ngRedux.configureStore(
rootReducer,
{},
[ createLogger() ],
[ ...enhancers, devTool.isEnabled() ? devTool.enhancer() : f => f]);
}
示例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);
示例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);
};