本文整理匯總了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;