本文整理汇总了TypeScript中redux-logger类的典型用法代码示例。如果您正苦于以下问题:TypeScript redux-logger类的具体用法?TypeScript redux-logger怎么用?TypeScript redux-logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了redux-logger类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: config
function config($ngReduxProvider) {
$ngReduxProvider.createStoreWith(rootReducer, [thunk, createLogger()])
}
开发者ID:,项目名称:,代码行数:3,代码来源:
示例17: createTracker
// `analyticsTracker` is Google Analytics. It's an argument here simply to allow injection
// in testing:
export default function getConfiguredStore(inputTracker: Function = null) {
function createTracker(analyticsAction: IAnalyticsAction<any>) {
const {
type,
payload: {
info
}
} = analyticsAction;
// This weird contraption is needed because:
// - We need to be able to inject a spy as a tracking function for testing so the tracking
// function can't be harccoded as `ga` all the time.
// - The `ga` function is defined twice in the app's lifetime. The first time, it is
// defined synchronously at the location of the google analytics snippet
// (so before the execution of the main app code.).
// However, this function doesn't actually send anything to GA. The `ga` function
// is then subsequently redefined by the `analytics.js` script loaded from `google-analytics.com`.
// This is the tracking function we want. The only problem is that the `script` tag for that
// `analytics.js` script is `async` so the redefinition happens after the app code has initialized.
// Thus, we can't just set `ga` as the default value for the `inputTracker` argument.
const actualTrackingFunction = (inputTracker === null) ? ga : inputTracker;
// If the payload's data is a primitive type, just send it. Otherwise,
// convert to JSOn string before sending:
const eventLabel = _.isObject(info) ? JSON.stringify(info) : info;
actualTrackingFunction('send', {
hitType: 'event',
eventCategory: 'interaction',
eventAction: type,
eventLabel
})
}
const analyticsMiddleware = reduxAnalytics(createTracker) as Middleware
let middlewares: Middleware[];
try {
if (process.env.NODE_ENV === 'development') {
// Add logger middleware in dev mode only:
middlewares = [thunk as Middleware, createLogger() as Middleware];
} else if (process.env.NODE_ENV === 'test') {
// Include analytics for for unit testing:
middlewares = [thunk as Middleware, analyticsMiddleware];
} else {
// Of course, analytics in production:
middlewares = [thunk as Middleware, analyticsMiddleware];
}
} catch(e) {
if (e.name === 'ReferenceError') {
console.log(e);
console.log('Must define the value of process.env.NODE_ENV global variable in webpack config. Treat as "development" for now.');
middlewares = [thunk as Middleware, createLogger() as Middleware];
} else {
throw e;
}
}
const enhancers = applyMiddleware(...middlewares);
// Redux store:
const store = createStore<IStoreState>(
reducer, {
// Let the store start out with an empty list of items:
items: undefined,
fetchStatus: undefined
} as IStoreState, enhancers)
// Persist the state to `localStorage` whenever the state changes but not more
// often than every 2 seconds:
// store.subscribe(_.throttle((state: IStoreState) => {
// saveLocalState(state);
// }, 2000));
return store;
}
开发者ID:huy-nguyen,项目名称:restaurant-menu-builder,代码行数:77,代码来源:getConfiguredStore.ts
示例18: configureStore
export default function configureStore() {
const store = createStore(reducers, compose(applyMiddleware(epicMiddleware, createLogger())));
return store;
}
开发者ID:zanjs,项目名称:wxapp-typescript,代码行数:4,代码来源:configureStore.ts
注:本文中的redux-logger类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论