当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript redux.applyMiddleware函数代码示例

本文整理汇总了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}
开发者ID:jiasaichao,项目名称:app,代码行数:31,代码来源:store.ts

示例2: configureStore

export default function configureStore() {
  const store = createStore(reducers, compose(applyMiddleware(epicMiddleware, createLogger())));
  return store;
}
开发者ID:zanjs,项目名称:wxapp-typescript,代码行数:4,代码来源:configureStore.ts

示例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' }]);
        });
}


开发者ID:0815fox,项目名称:DefinitelyTyped,代码行数:26,代码来源:redux-promise-tests.ts

示例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
})
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:30,代码来源:redux-storage-tests.ts

示例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)
  )
);
开发者ID:andresLopera,项目名称:g3r,代码行数:12,代码来源:store.ts

示例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);


开发者ID:mrmodise,项目名称:senepe,代码行数:13,代码来源:store.ts

示例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);
}
开发者ID:wsquared,项目名称:property-listing,代码行数:11,代码来源:configureStore.ts

示例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');
开发者ID:aocenas,项目名称:PantryApp,代码行数:22,代码来源:create-store.ts

示例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));
开发者ID:Layoric,项目名称:Gistlyn,代码行数:30,代码来源:state.ts

示例10: createStore

export const createAppStore = () => createStore(rootReducer, applyMiddleware(thunk.default, logger));
开发者ID:josephjeganathan,项目名称:react-redux-typescript,代码行数:1,代码来源:store.ts


注:本文中的redux.applyMiddleware函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。