}, { 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}
export default function configureStore() { const store = createStore(reducers, compose(applyMiddleware(epicMiddleware, createLogger()))); return store; }
/// <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: '*****@*****.**' }]); }); }
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 })
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) ) );
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);
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); }
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');
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));
export const createAppStore = () => createStore(rootReducer, applyMiddleware(thunk.default, logger));