本文整理匯總了TypeScript中react-redux-loading-bar.loadingBarMiddleware函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript loadingBarMiddleware函數的具體用法?TypeScript loadingBarMiddleware怎麽用?TypeScript loadingBarMiddleware使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了loadingBarMiddleware函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: composeEnhancers
const rootStore = () => {
const store = createStore<RootState>(
rootReducer,
composeEnhancers(
applyMiddleware(
loadingBarMiddleware(),
thunk
)
)
)
return store
}
示例2: promiseMiddleware
import { createStore, applyMiddleware, compose } from 'redux';
import promiseMiddleware from 'redux-promise-middleware';
import thunkMiddleware from 'redux-thunk';
import reducer, { IRootState } from 'app/shared/reducers';
import DevTools from 'app/config/devtools';
import errorMiddleware from 'app/config/error-middleware';
import notificationMiddleware from 'app/config/notification-middleware';
import loggerMiddleware from 'app/config/logger-middleware';
import { loadingBarMiddleware } from 'react-redux-loading-bar';
const defaultMiddlewares = [
thunkMiddleware,
errorMiddleware,
notificationMiddleware,
promiseMiddleware(),
loadingBarMiddleware(),
loggerMiddleware
];
const composedMiddlewares = middlewares =>
process.env.NODE_ENV === 'development'
? compose(
applyMiddleware(...defaultMiddlewares, ...middlewares),
DevTools.instrument()
)
: compose(applyMiddleware(...defaultMiddlewares, ...middlewares));
// 創建 Redux store 來存放應用的狀態。
const initialize
= ((initialState?: IRootState, middlewares = []) => createStore(reducer, initialState, composedMiddlewares(middlewares)));
// 擴展示例:
// 每次 state 更新時,打印日誌
// 注意 subscribe() 返回一個函數用來注銷監聽器
示例3: makeImmutable
const language = localStorage.getItem("impera-lang") || "en";
const initialData = Object.assign({}, sessionData, { language: language });
const initialSessionState = initialData && makeImmutable(initialData) as ISessionState || undefined;
export let store = Redux.createStore<IState>(
rootReducer,
{
// Pre-populate stored session data
session: initialSessionState
} as IState,
compose(
Redux.applyMiddleware(
routerMiddleware(browserHistory as any),
loadingBarMiddleware({
promiseTypeSuffixes: [pending(""), success(""), failed("")]
}),
promiseMiddleware as any,
thunkMiddleware.withExtraArgument({
getCachedClient: getCachedClient,
createClientWithToken: createClientWithToken,
getSignalRClient: getSignalRClient
} as IAsyncActionDependencies),
(createLogger as any)())));
// Persist session settings to session storage
store.subscribe(debounce(() => {
const state = store.getState();
const sessionState = state && state.session;
if (sessionState) {