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