本文整理汇总了TypeScript中redux-devtools-extension.composeWithDevTools函数的典型用法代码示例。如果您正苦于以下问题:TypeScript composeWithDevTools函数的具体用法?TypeScript composeWithDevTools怎么用?TypeScript composeWithDevTools使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了composeWithDevTools函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: configureStore
export default function configureStore(): Store<IApplicationState> {
const epicMiddleware = createEpicMiddleware()
const middlewares = [
epicMiddleware,
notificationsMiddleware,
]
const store = createStore(
rootReducer,
composeWithDevTools(
applyMiddleware(...middlewares)
)
)
epicMiddleware.run(rootEpic)
return store
}
示例2: createRouter
export const configureStore = (
initialState?: GenericObject,
initialEntries?: GenericObject,
) => {
const options = { initialEntries };
const { reducer, middleware, firstRoute } = createRouter(appRoutes, options);
const epicMiddleware = createEpicMiddleware();
const middlewares = applyMiddleware(middleware, epicMiddleware);
const enhancers = composeWithDevTools(middlewares);
const store = createStore(
createRootReducer({ page: pageReducer, location: reducer }),
initialState,
enhancers,
);
epicMiddleware.run(createRootEpic() as any);
return { store, firstRoute };
};
示例3: configureStore
export default function configureStore(preloadedState: object) {
const middlewares: Middleware[] = [
fileHandlerMiddleware,
loggerMiddleware,
subtitleMiddleware,
];
const middlewareEnhancer = applyMiddleware(...middlewares);
const store = createStore(
rootReducer,
preloadedState,
composeWithDevTools(middlewareEnhancer),
);
if (process.env.NODE_ENV !== 'production' && module.hot) {
module.hot.accept('./rootReducer', () => store.replaceReducer(rootReducer));
}
return store;
}
示例4: configureStore
export default function configureStore(
initialState: any,
): Store<IState> {
const middlewares = [thunk];
const middlewareEnhancer = composeWithDevTools(applyMiddleware(...middlewares));
const store = createStore(
rootReducer,
initialState,
middlewareEnhancer,
);
if (process.env.NODE_ENV !== 'production') {
if (module.hot) {
module.hot.accept('../reducers/rootReducer', () => {
store.replaceReducer(rootReducer);
});
}
}
return store;
}
示例5: configureStore
export default function configureStore(
referenceDataService,
blotterService,
pricingService,
analyticsService,
compositeStatusService,
executionService,
openFin
) {
const middleware = epicMiddleware(
referenceDataService,
blotterService,
pricingService,
analyticsService,
compositeStatusService,
executionService,
openFin
)
const store = createStore(rootReducer, composeWithDevTools(applyMiddleware(middleware)))
persistStore(store)
return store
}
示例6: composeWithDevTools
import { createStore, applyMiddleware, DeepPartial } from "redux";
import thunk from "redux-thunk";
import { composeWithDevTools } from "redux-devtools-extension";
import reducer from "./reducers";
import mediaMiddleware from "./mediaMiddleware";
import { merge } from "./utils";
import { UPDATE_TIME_ELAPSED, STEP_MARQUEE } from "./actionTypes";
import Media from "./media";
import Emitter from "./emitter";
import { Extras, Dispatch, Action, AppState, Middleware } from "./types";
// TODO: Move to demo
const compose = composeWithDevTools({
actionsBlacklist: [UPDATE_TIME_ELAPSED, STEP_MARQUEE],
});
export default function(
media: Media,
actionEmitter: Emitter,
customMiddlewares: Middleware[] = [],
stateOverrides: DeepPartial<AppState> | undefined,
extras: Extras
) {
let initialState;
if (stateOverrides) {
initialState = merge(
reducer(undefined, { type: "@@init" }),
stateOverrides
);
}
示例7: composeWithDevTools
import {
Action,
Middleware,
Reducer,
applyMiddleware,
createStore
} from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';
const composeEnhancers = composeWithDevTools();
const reducer: Reducer<{}> = () => ({});
const middleware: Middleware[] = [];
const store = createStore(reducer, composeEnhancers(
applyMiddleware(...middleware)
));
const store2 = createStore(reducer, composeWithDevTools({
serialize: {
options: {
undefined: true,
function: (fn: any) => fn.toString()
}
}
}));
const store3 = createStore(reducer, composeWithDevTools({
serialize: {
replacer: (key, value) => 'foo'
}
}));
示例8: composeWithDevTools
import { createStore, compose, applyMiddleware, Middleware } from 'redux';
// import { createEpicMiddleware } from 'redux-observable';
import { composeWithDevTools } from 'redux-devtools-extension';
import createRootReducer from './app.reducers';
const middlewares: Array<Middleware> = [];
const enhancers =
process.env.REACT_APP_ENV !== 'prod'
? composeWithDevTools(applyMiddleware(...middlewares))
: compose(applyMiddleware(...middlewares));
export const createNewStore = () => {
return createStore(createRootReducer(), {}, compose(enhancers));
};
export default createNewStore;
示例9: createStore
import { createStore, combineReducers, applyMiddleware } from "redux";
import { reducer as greetingReducer } from "./greeting";
import thunk from "redux-thunk";
import { composeWithDevTools } from "redux-devtools-extension";
export type State = {
greeting: string;
};
const store = createStore(
combineReducers({
greeting: greetingReducer
}),
composeWithDevTools(applyMiddleware(thunk))
);
export default store;
示例10: userReducer
import { applyMiddleware, combineReducers, compose, createStore, Middleware, MiddlewareAPI } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';
import thunk from 'redux-thunk';
import { UserActionTypes, FactActionTypes } from './actions';
import { factReducer, userReducer } from './reducers';
import { AppState } from './models';
import { initialAppState } from './models/app';
type ActionTypes = UserActionTypes | FactActionTypes;
const appReducer = (state: AppState = initialAppState, action: ActionTypes): AppState => {
return {
userState: userReducer(state.userState, action),
actualState: factReducer(state.actualState, action)
};
};
// thunkMiddleware enables async actions (like fetch or promises)
// authRefreshMiddleware dispatches a thunk, so put it before thunk
const store = createStore(appReducer, initialAppState, composeWithDevTools(
applyMiddleware(thunk),
));
export default store;