當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。