本文整理汇总了TypeScript中redux.applyMiddleware函数的典型用法代码示例。如果您正苦于以下问题:TypeScript applyMiddleware函数的具体用法?TypeScript applyMiddleware怎么用?TypeScript applyMiddleware使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了applyMiddleware函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: routerMiddleware
},
{
id: 5, pid: 2, title: '表格', href: '#/index/table'
},
{
id: 6, pid: 2, title: '一般', href: '#/index/general'
},
{
id: 7, pid: 3, title: '表格', href: '#/index/table'
},
{
id: 8, pid: 3, title: '一般', href: '#/index/general'
},
{
id: 9, pid: 3, title: '表格', href: '#/index/table'
}
]
}
};
const middleware = routerMiddleware(browserHistory)
//监听全局数据
import indexReducer from './reducers/index';
let store = createStore(
(state, action) => {
/*没有直接放indexReducer是因为这里可以增加其他需要执行的函数,增加扩展性 */
let nextState=indexReducer(state,action);
/*这里可以再次处理nextState*/
return nextState;
},
applyMiddleware(thunkMiddleware,middleware));
export {store}
示例2: configureStore
export default function configureStore() {
const store = createStore(reducers, compose(applyMiddleware(epicMiddleware, createLogger())));
return store;
}
示例3: createStore
/// <reference path="redux-promise.d.ts" />
/// <reference path="../redux/redux.d.ts" />
/// <reference path="../redux-actions/redux-actions.d.ts" />
import {createAction} from 'redux-actions';
import { createStore, applyMiddleware } from 'redux';
import promise from 'redux-promise';
import PromiseInterface = ReduxPromise.PromiseInterface;
declare var userReducer: any;
const appStore = createStore(userReducer, applyMiddleware(
promise
));
appStore.dispatch(
listUsers()
);
function listUsers(): PromiseInterface {
return createAction('LIST_USERS',
() => {
return Promise.resolve([{ email: 'me@definitely.typed' }]);
});
}
示例4: rootReducer
b: string;
c: string;
}
function rootReducer(state: TestState, action: Action): TestState {
return state;
}
const enhancedReducer = reducer(rootReducer, reduxStorageImmutableMerger);
const storageEngine = filter(createEngine("test"), ['a', 'b'], ['c']);
const initialStateLoader = createLoader(storageEngine);
const storageMiddleware = createMiddleware(storageEngine, [], []);
const store = applyMiddleware(storageMiddleware)<TestState>(createStore)(enhancedReducer);
initialStateLoader(store).then(() => {
// render app
})
// Test for React Native Async Storage engine
const storageEngineReactNative = createReactNativeAsyncStorageEngine("test");
const storageMiddlewareReactNative = createMiddleware(storageEngine);
const storeReactNative = applyMiddleware(storageMiddlewareReactNative)<TestState>(createStore)(enhancedReducer);
initialStateLoader(storeReactNative).then(() => {
// render app
})
示例5: createStore
import { Store, createStore, compose, applyMiddleware } from 'redux';
import reduxThunk from 'redux-thunk';
import { reducer, State } from './state';
export const store: Store<State> = createStore(
reducer,
compose(
applyMiddleware(reduxThunk)
)
);
示例6: compose
import {applyMiddleware, compose, createStore, GenericStoreEnhancer} from 'redux';
import {IAppState} from './IAppState';
import {reducer} from './reducers';
import freezeState from './freezeState';
// set up dev tools
declare var window: any;
const devToolsExtension: GenericStoreEnhancer = (window.devToolsExtension)
? window.devToolsExtension() : (f) => f;
export const store = createStore<IAppState>(reducer,
compose(applyMiddleware(freezeState),
devToolsExtension) as GenericStoreEnhancer);
示例7: require
import { createStore, applyMiddleware, combineReducers } from 'redux';
import propertyList from '../reducers/property-list-reducer';
const thunk = require('redux-thunk').default;
const rootReducer = combineReducers({ propertyList });
const finalCreateStore = applyMiddleware(thunk)(createStore);
export default () => {
return finalCreateStore(rootReducer);
}
示例8: combineReducers
import {createStore, combineReducers, applyMiddleware} from 'redux';
import thunkMiddleware from 'redux-thunk';
import {OpaqueToken} from '@angular/core';
import usersReducer from '../users/users.reducer';
import itemsReducer from '../pantry-list/items.reducer';
import statsReducer from '../stats/stats.reducer';
// combine reducers
const rootReducer = combineReducers({
users: usersReducer,
items: itemsReducer,
stats: statsReducer,
});
export const store = createStore(
rootReducer,
applyMiddleware(
thunkMiddleware
)
);
export const STORE_TOKEN = new OpaqueToken('store');
示例9: Date
return Object.assign({}, state, { dialog: action.dialog });
case 'DIRTY_SET':
return Object.assign({}, state, { dirty: action.dirty });
case 'COLLECTION_CHANGE':
return Object.assign({}, state, { collection: action.collection, showCollection: action.showCollection, url: action.collection && action.collection.id });
case 'COLLECTION_LOAD':
return Object.assign({}, state, { collection: action.collection, showCollection: true });
case 'SNAPSHOT_LOAD':
return Object.assign({}, state, action.snapshot, { activeSub: state.activeSub });
case 'GISTSTAT_INCR':
const gistStats = state.gistStats;
const existingStat = gistStats[action.gist];
const step = state.step || 1;
return Object.assign({}, state, {
gistStats: existingStat
? Object.assign({}, gistStats, {
[action.gist]: Object.assign({}, existingStat, { [action.stat]: (existingStat[action.stat] || 0) + step, date: new Date().getTime() })
})
: Object.assign({}, gistStats, { [action.gist]: { id:action.gist, description: action.description, collection:action.collection, [action.stat]: step, owner_login:action.owner_login, date:new Date().getTime() } })
});
case 'GISTSTAT_REMOVE':
var clone = Object.assign({}, state.gistStats);
delete clone[action.gist];
return Object.assign({}, state, { gistStats: clone });
default:
return state;
}
},
defaults,
applyMiddleware(stateSideEffects));
示例10: createStore
export const createAppStore = () => createStore(rootReducer, applyMiddleware(thunk.default, logger));