本文整理汇总了TypeScript中redux-logger.createLogger函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createLogger函数的具体用法?TypeScript createLogger怎么用?TypeScript createLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createLogger函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: loadState
const configureStore = () => {
const persistedState = loadState();
let middleware = [thunkMiddleware];
let newMiddleware = [];
if (process.env.NODE_ENV !== 'production') {
const loggerMiddleware = createLogger();
newMiddleware = [...middleware, loggerMiddleware];
} else {
newMiddleware = middleware;
}
const store = createStore<AppState>(
appReducer,
// persistedState,
applyMiddleware(...newMiddleware)
);
let token = getToken();
if (token !== null) {
store.dispatch(receiveTokenActionCreator(token.user, token));
}
store.subscribe(_.throttle(() => {
saveState(store.getState());
}, 1000));
return store;
};
开发者ID:ttsvetanov,项目名称:polyaxon,代码行数:29,代码来源:configureStore.ts
示例2: constructor
constructor(
private ngRedux: NgRedux<IAppState>,
private devTool: DevToolsExtension,
private rootEpic: RootEpic,
private router: Router,
) {
const middleware = [
createEpicMiddleware(this.rootEpic.combineAll()),
createLogger(),
];
const reducer = compose(
mergePersistedState()
)(rootReducer);
const storage = compose(
filter('auth')
)(adapter(window.localStorage));
const enhancers = [
persistState(storage, 'fyibn/store'),
];
if (devTool.isEnabled()) {
enhancers.push(devTool.enhancer());
}
this.ngRedux.configureStore(
reducer,
{} as IAppState,
middleware,
enhancers,
);
}
开发者ID:pusherman,项目名称:fyibn-ui,代码行数:34,代码来源:app.component.ts
示例3: default
export default (history: History, dsn: string) => {
const sagaMiddleware: SagaMiddleware<{}> = createSagaMiddleware();
let middlewares: Middleware[] = [];
if (process.env.NODE_ENV !== 'production') {
middlewares = [
createLogger(),
];
}
Raven.config(dsn).install();
const devtools: any = process.env.NODE_ENV !== 'production' && (window as any)._REDUX_DEVTOOLS_EXTENSION__ ?
(window as any)._REDUX_DEVTOOLS_EXTENSION__() : (f: any) => f;
const store = createStore(
createRootReducer(history),
compose(
applyMiddleware(
routerMiddleware(history),
googleAnalytics,
sagaMiddleware,
createRavenMiddleware(Raven, {}),
...middlewares,
),
devtools,
),
);
sagaMiddleware.run(rootSaga);
return store;
};
开发者ID:8398a7,项目名称:8398a7.github.io,代码行数:27,代码来源:store.ts
示例4: createSagaMiddleware
export const configureStore = () => {
const sagaMiddleware = createSagaMiddleware()
const logger = createLogger()
const store = createStore(
persistReducer({ key: 'reversi', storage, whitelist: ['history'] }, reducer),
compose(
applyMiddleware(sagaMiddleware, logger),
getDevtools()
)
)
const persistor = persistStore(store)
if (module.hot) {
module.hot.accept('./reducer', () => {
store.replaceReducer(require('./reducer').default)
})
}
return {
store,
persistor,
runSaga: sagaMiddleware.run,
close () {
store.dispatch(END as any)
}
}
}
开发者ID:DanSnow,项目名称:react-reversi,代码行数:27,代码来源:store.ts
示例5: constructor
constructor(
private ngRedux: NgRedux<IAppState>,
private devTool: DevToolsExtension) {
// configure the store here, this is where the enhancers are set
this.ngRedux.configureStore(rootReducer, {},
isDevMode() ? [createLogger({ collapsed: true })] : [],
isDevMode() && devTool.isEnabled() ? [...enhancers, devTool.enhancer()] : [...enhancers]);
}
开发者ID:projectSHAI,项目名称:expressgular2,代码行数:9,代码来源:redux.module.ts
示例6: configureStore
export function configureStore() {
const composeEnhancers = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
if (process.env.NODE_ENV !== 'production') {
// DEV builds we had the logger middleware
store = createStore(rootReducer, {}, composeEnhancers(applyMiddleware(thunk, createLogger())));
} else {
store = createStore(rootReducer, {}, composeEnhancers(applyMiddleware(thunk)));
}
}
开发者ID:ArcticSnowman,项目名称:grafana,代码行数:10,代码来源:configureStore.ts
示例7: logger
export function logger() {
const craftedLogger = createLogger({
// predicate: (getState, action) => action.type.includes('COMM'),
stateTransformer: (state: any) =>
Object.keys(state).reduce(
(prev, key) =>
Object.assign({}, prev, {
[key]: isCollection(state[key]) ? state[key].toJS() : state[key]
}),
{}
)
});
return craftedLogger;
}
开发者ID:kelleyblackmore,项目名称:nteract,代码行数:14,代码来源:middlewares.ts
示例8: createLogger
export const createAppStore = (initialState?: ApplicationStore): Store<ApplicationStore> => {
if (appStore) {
return appStore;
}
const middlewares = [
thunk,
createLogger(),
];
appStore = createStore<ApplicationStore>(rootReducer, initialState, compose(
applyMiddleware(...middlewares),
));
return appStore;
};
开发者ID:jmptr,项目名称:lost-sloth,代码行数:15,代码来源:store.ts
示例9: initializeStore
export default function initializeStore(
context: ThunkContext,
save: (state: Object) => Promise<void>,
restore: (keys: string[]) => Promise<any>
): Store<State, Event> {
const middlewares: Middleware<State, Event>[] = [
errorHandlingMiddleware((error, { dispatch }) => {
const errorString = (error + '') || 'Unknown error occured';
dispatch(sendNotification(
errorString,
'negative',
0
));
}),
thunkMiddleware(context),
saveStateMiddleware(save, 1000)
];
if (process.env.NODE_ENV !== 'production') {
middlewares.push(reduxMiddleware(createLogger({ duration: true })));
}
const store = applyMiddlewares(createStore(reducer, initialState), middlewares);
restore(Object.keys(initialState)).then((partialState) => {
const state = {
...mergeState(store.getState(), partialState),
version: packageJson.version
};
store.replaceState(state);
store.dispatch({
type: 'APPLICATION_INITIALIZED'
});
});
return store;
}
开发者ID:emonkak,项目名称:feedpon,代码行数:40,代码来源:initializeStore.ts
示例10: configureStore
export default function configureStore(defaultState?: State) {
const middlewares = [ravenMiddleware, thunk, requestsMiddleware];
if (process.env.NODE_ENV === 'development') {
/* eslint-disable */
const { createLogger } = require('redux-logger');
/* eslint-enable */
const logger = createLogger({
level: 'info',
collapsed: true,
duration: true,
diff: true,
// Avoid diffing actions that insert a lot of stuff into the state to prevent console from lagging
diffPredicate: (getState: GetState, action: FSA) =>
!action.type.startsWith('FETCH_MODULE_LIST') && !action.type.startsWith('persist/'),
});
middlewares.push(logger);
}
const storeEnhancer = applyMiddleware(...middlewares);
const store: Store<State, any> = createStore(
rootReducer,
// @ts-ignore TODO: Figure out why undefined isn't accepted
defaultState,
composeEnhancers(storeEnhancer),
);
if (module.hot) {
// Enable webpack hot module replacement for reducers
module.hot.accept('../reducers', () => store.replaceReducer(rootReducer));
}
const persistor = persistStore(store);
return { persistor, store };
}
开发者ID:nusmodifications,项目名称:nusmods,代码行数:36,代码来源:configure-store.ts
注:本文中的redux-logger.createLogger函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论