本文整理匯總了TypeScript中redux.combineReducers函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript combineReducers函數的具體用法?TypeScript combineReducers怎麽用?TypeScript combineReducers使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了combineReducers函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: toIdValue
warbandMember: (_: any, args: any) => toIdValue(dataIdFromObject({ __typename: 'WarbandMember', id: args['id'] })),
character: (_: any, args: any) => toIdValue(dataIdFromObject({ __typename: 'Character', id: args['id'] })),
},
};
export const apollo = new ApolloClient({
addTypename: true,
customResolvers,
dataIdFromObject,
networkInterface,
queryDeduplication: true,
});
const reducer = combineReducers({
apollo: apollo.reducer() as any,
layout,
invites,
});
export default reducer;
export interface SessionState {
apollo : any;
layout: LayoutState;
invites: InvitesState;
}
const composeEnhancers = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
export const store =
createStore(reducer, composeEnhancers(applyMiddleware(apollo.middleware(), thunkMiddleware, crashReporterMiddleware)));
示例2: require
import { combineReducers } from 'redux';
const persistState = require('redux-localstorage');
import { counterReducer } from './counter.reducer';
import { IPathDemoData, pathDemoReducer } from './path-demo.reducer';
import { ISearchState, searchReducer } from './search.reducer';
export interface IAppState {
counter?: number;
pathDemo?: IPathDemoData;
search?: ISearchState;
};
export const rootReducer = combineReducers<IAppState>({
counter: counterReducer,
pathDemo: pathDemoReducer,
search: searchReducer
});
export const enhancers = [
persistState('counter', { key: 'ng2-redux/examples/counter' })
];
示例3: switch
switch(action.type) {
case 'LOAD_BLOCKS':
return assign({}, state, { blocksLoaded: 0 });
case 'RECV_BLOCKS':
return assign({}, state, { blocksLoaded: action.when });
case 'LOAD_BLUEPRINTS':
return assign({}, state, { blueprintsLoaded: 0 });
case 'RECV_BLUEPRINTS':
return assign({}, state, { blueprintsLoaded: action.when });
case 'COPY_BLUEPRINT':
return assign({}, state, { blueprintCopied: action.when });
}
return state;
}
// ==== BuildingState =====
export interface BuildingState {
ui: UIState;
selection: SelectionState;
blocks: BlocksState;
filter: FilterState;
}
const building = combineReducers({ ui, selection, blocks, filter });
// ==== store ====
export const store = createStore(building);
export default store;
示例4: combineReducers
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { combineReducers } from 'redux';
import { embeddablesReducer } from './embeddables';
import { panelsReducer } from './panels';
import { viewReducer } from './view';
import { metadataReducer } from './metadata';
export const dashboard = combineReducers({
embeddables: embeddablesReducer,
metadata: metadataReducer,
panels: panelsReducer,
view: viewReducer,
});
示例5: combineReducers
import {combineReducers} from 'redux';
import question from './questionReducer';
import answer from './answerReducer';
import tag from './tagReducer';
import account from './accountReducer';
import form from './formReducer';
import display from './displayReducer';
const reducer = combineReducers({
question,
answer,
tag,
account,
form,
display
});
export default reducer;
示例6: switch
};
export const allIdApplicationReducer = (state: number[] = [], action: AjaxifyAction | ApplicationAction = Action) => {
switch (action.type) {
case AJAXIFY_APPLICATION_LIST:
return action.payload.applications.map(x => x.appId);
case AJAXIFY_APPLICATION:
return state.indexOf(action.payload.application.appId) === -1
? [...state, action.payload.application.appId]
: state;
case DELETE_APPLICATION_SUCCESS:
const index = state.indexOf(action.payload.appId);
return index !== -1
? [...state.slice(0, index), ...state.slice(index + 1)]
: state;
default:
return state;
}
};
export const applicationReducer = combineReducers<ApplicationDbState>({
byId: byIdApplicationReducer,
allIds: allIdApplicationReducer
});
export const dbReducer = combineReducers<DbState>({
applications: applicationReducer,
blogPosts: blogPostReducer,
});
示例7: routerMiddleware
import { syncHistoryWithStore, routerReducer, routerMiddleware, push, replace } from 'react-router-redux';
import { createStore, combineReducers, applyMiddleware } from 'redux';
import { browserHistory } from 'react-router';
import thunk from 'redux-thunk';
import promiseMiddleware from 'redux-promise-middleware';
import CurrentUser from './reducers/authorize/reducer';
import UsersRepository from './reducers/users/usersReducer';
const middleware = routerMiddleware(browserHistory);
let reudcers = combineReducers({
CurrentUser,
UsersRepository,
routing: routerReducer,
});
const logger = store => next => action => {
console.log('dispatching', action);
let result = next(action);
console.log('next state', store.getState());
return result;
};
export var store = createStore<store.IApplicationStore>(reudcers, applyMiddleware(middleware, thunk, promiseMiddleware(), logger));
export var navigate = (path: string): void => {
store.dispatch(replace(path));
};
示例8:
readonly authentication: AuthenticationState;
readonly locale: LocaleState;
readonly applicationProfile: ApplicationProfileState;
readonly administration: AdministrationState;
readonly userManagement: UserManagementState;
readonly register: RegisterState;
readonly activate: ActivateState;
readonly passwordReset: PasswordResetState;
readonly password: PasswordState;
readonly settings: SettingsState;
/* jhipster-needle-add-reducer-type - JHipster will add reducer type here */
readonly loadingBar: any;
}
const rootReducer = combineReducers<IRootState>({
authentication,
locale,
applicationProfile,
administration,
userManagement,
register,
activate,
passwordReset,
password,
settings,
/* jhipster-needle-add-reducer-combine - JHipster will add reducer here */
loadingBar
});
export default rootReducer;
示例9: combineReducers
import { combineReducers } from "redux"
import { routerReducer } from 'react-router-redux'
import { IStore } from "store"
import userReducer from 'user-reducer';
const storeData: IStore = {
user: userReducer,
routing: routerReducer
}
export default combineReducers(storeData)
示例10: combineReducers
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { combineReducers } from 'redux';
import materialsByTypeReducer, { MaterialsByTypeState } from './materials-by-type';
const materialSelector = materialsByTypeReducer;
export default combineReducers({
materialSelector,
});
export interface GlobalState {
materialSelector: MaterialsByTypeState;
}