示例#1
3
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));
};
示例#2
0
    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)));
示例#3
0
文件: Building.ts 项目: Fidaman/cu-ui
  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
0
文件: index.ts 项目: 9590/ng2-redux
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' })
];

示例#5
0
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
0
文件: index.ts 项目: Jaaess/kibana
 * 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,
});
};

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,
});
示例#8
0
文件: index.ts 项目: gjik911/git_01
  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;
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
0
/**
 * 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;
}