本文整理汇总了TypeScript中ngrx-store-logger.storeLogger函数的典型用法代码示例。如果您正苦于以下问题:TypeScript storeLogger函数的具体用法?TypeScript storeLogger怎么用?TypeScript storeLogger使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了storeLogger函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: rootReducer
export function rootReducer (state: AppBackgroundState, action: Action) {
if (action.type === 'SET_NEW_STATE') {
state = Object.assign({}, state, action.payload);
}
if (!environment.production) {
return compose(storeLogger(), combineReducers)(appBackgroundState)(state, action);
} else {
return compose(combineReducers)(appBackgroundState)(state, action);
}
}
示例2: main
export function main() {
return bootstrap(AsyncApp, [
HTTP_PROVIDERS,
provideStore(
storeLogger()(combineReducers({selectedReddit, postsByReddit}))
),
runEffects(RedditEffects),
Reddit
])
.catch(err => console.error(err));
}
示例3: compose
books: fromBooks.BooksState;
cubes: fromCubes.CubesState;
collection: fromCollection.CollectionState;
cube_collection: fromCubesCollection.CollectionState;
tree: fromTree.TreesState
}
/**
* Because metareducers take a reducer function and return a new reducer,
* we can use our compose helper to chain them together. Here we are
* using combineReducers to make our top level reducer, and then
* wrapping that in storeLogger. Remember that compose applies
* the result from right to left.
*/
export default compose(storeLogger(), combineReducers)({
router: routerReducer,
search: searchReducer,
cubes_search: cubes_searchReducer,
books: booksReducer,
cubes: cubesReducer,
collection: collectionReducer,
cube_collection: cubes_collectionReducer,
tree: tree_Reducer
});
/**
* A selector function is a map function factory. We pass it parameters and it
* returns a function that maps from the larger state tree into a smaller
* piece of state. This selector simply selects the `books` state.
示例4: stateSetter
import { storeFreeze } from 'ngrx-store-freeze';
import { storeLogger } from 'ngrx-store-logger';
import { reducers } from './root';
export { reducers, AppState } from './root';
declare const ENV: string;
// Generate a reducer to set the root state in dev mode for HMR
function stateSetter(reducer: ActionReducer<any>): ActionReducer<any> {
return function(state, action) {
if (action.type === 'SET_ROOT_STATE') {
return action.payload;
}
return reducer(state, action);
};
}
const DEV_REDUCERS = [stateSetter, storeFreeze, storeLogger()];
const developmentReducer = compose(...DEV_REDUCERS, combineReducers)(reducers);
const productionReducer = compose(combineReducers)(reducers);
export function rootReducer(state: any, action: any) {
if (ENV !== 'development') {
return productionReducer(state, action);
} else {
return developmentReducer(state, action);
}
}
示例5: compose
import { compose } from '@ngrx/core/compose';
import { storeLogger } from 'ngrx-store-logger';
import { combineReducers } from '@ngrx/store';
import { itemReducer } from './item/item.reducer';
export const appReducer = compose(storeLogger(), combineReducers)({
item: itemReducer,
});
示例6: compose
import { storeLogger } from 'ngrx-store-logger';
import { localStorageSync } from 'ngrx-store-localstorage';
import { IState as ICounterState, reducer as counterReducer } from './counter';
import { IState as IUserState, reducer as userReducer } from './user';
import { IState as IConfigState, reducer as configReducer } from './config';
// application state interface
export interface IState {
router: RouterState;
config: IConfigState;
counter: ICounterState;
user: IUserState;
}
// app level reducers
export const reducers = {
router: routerReducer,
config: configReducer,
counter: counterReducer,
user: userReducer
};
// root reducer
export const reducer: ActionReducer<IState> = compose(
storeLogger(),
storeFreeze,
localStorageSync(keys(reducers), true),
combineReducers
)(reducers);
示例7: compose
auth: AuthState;
schedules: ScheduleState;
speakers: SpeakerState;
map: MapState;
}
/**
* Because metareducers take a reducer function and return a new reducer,
* we can use our compose helper to chain them together. Here we are
* using combineReducers to make our top level reducer, and then
* wrapping that in storeLogger. Remember that compose applies
* the result from right to left.
*/
const reducers = {
map: mapReducer,
speakers: speakerReducer,
schedules: scheduleReducer,
auth: authReducer
};
const developmentReducer = compose(storeFreeze, storeLogger(), combineReducers)(reducers);
const productionReducer = combineReducers(reducers);
export function reducer(state: any, action: any) {
if (process.env.NODE_ENV === 'production') {
return productionReducer(state, action);
} else {
return developmentReducer(state, action);
}
}
示例8: logger
export function logger(_reducer: ActionReducer<any>): any {
return storeLogger()(_reducer);
}
示例9: compose
// Re export symbol for commodity
export { Store, Action, State } from '@ngrx/store';
import { REDUCERS as PROJECTS_REDUCER } from './projects.reducer';
var REDUCERS = Object.assign({}, PROJECTS_REDUCER);
export var PROVIDERS: Array<any> = [];
const initialState = {
}
import { StoreModule, combineReducers } from '@ngrx/store';
import { compose } from '@ngrx/core';
import { storeLogger } from 'ngrx-store-logger';
export const MODULE =
StoreModule.provideStore(
compose(
storeLogger({ collapsed: true }),
combineReducers
)(REDUCERS),
initialState);
示例10: logger
export function logger(reducer: ActionReducer<State>): any {
return storeLogger({
collapsed: true
})(reducer);
}