本文整理汇总了TypeScript中redux.createStore函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createStore函数的具体用法?TypeScript createStore怎么用?TypeScript createStore使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createStore函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: prod
function prod() {
return createStore(rootReducer as any, ({} as any), getMiddleware("production"));
}
开发者ID:creimers,项目名称:Farmbot-Web-API,代码行数:3,代码来源:store.ts
示例2: next
return title;
}
});
const dumbMiddleware: Middleware = store => next => action => next(action);
const composedMiddleware = applyMiddleware(middleware, dumbMiddleware);
const storeEnhancer = compose<StoreCreator, StoreCreator, StoreCreator>(
enhancer,
composedMiddleware
);
const combined = combineReducers<State>({ location: reducer });
const store = createStore(combined, storeEnhancer);
// Test that `thunk()` has correct state types now that `store` is defined
thunk(store)
.then((t) => {
t = t!; // $ExpectType RouteThunk<State>
});
const receivedAction: ReceivedAction = {
type: 'HOME',
payload: {}
};
actionToPath(receivedAction, routesMap); // $ExpectType string
const querySerializer: QuerySerializer = {
stringify: (params) => '',
开发者ID:Dru89,项目名称:DefinitelyTyped,代码行数:31,代码来源:redux-first-router-tests.ts
示例3: return
}
const rootReducer: Reducer<State> = () => ({});
const asyncNotify: BatchFunction = (() => {
let notifying = false;
return (notify: NotifyFunction) => {
if (notifying) {
return;
}
notifying = true;
setTimeout(() => {
notify();
notifying = false;
});
};
})();
const store = createStore(
rootReducer,
batchedSubscribe(asyncNotify)
);
const unsubscribe = store.subscribeImmediate(() => {
store.getState();
});
unsubscribe();
开发者ID:Lavoaster,项目名称:DefinitelyTyped,代码行数:30,代码来源:redux-batched-subscribe-tests.ts
示例4: createStore
// TodoStore (store.ts)
import {combineReducers, createStore, Store} from 'redux';
import {todos} from './reducers/todos';
// Create the store using the todos reducer
export const TodoStore: Store = createStore(todos);
// Publish action to add a new Todo
export const addTodo: Function = (title: String) : void => {
// Dispatch will publish an action of type 'ADD_TODO', which
// runs through the reducer and gets caught in the
// case 'ADD_TODO': block
TodoStore.dispatch({
type: 'ADD_TODO',
title
})
}
// Publish action to toggle a Todo
export const toggleTodo: Function = (index: Number) : void => {
TodoStore.dispatch({
type: 'TOGGLE_TODO',
index
})
}
开发者ID:HansS,项目名称:angular2-samples-jason-aden,代码行数:25,代码来源:store.ts
示例5: combineReducers
routerMiddleware,
push,
replace,
go,
goForward,
goBack,
routerActions
} from 'react-router-redux';
const reducer = combineReducers({ routing: routerReducer });
// Apply the middleware to the store
const browserHistory = createHistory()
const middleware = routerMiddleware(browserHistory);
const store = createStore(
reducer,
applyMiddleware(middleware)
);
// Create an enhanced history that syncs navigation events with the store
const history = syncHistoryWithStore(browserHistory, store);
history.listen(location => console.log(location) );
history.unsubscribe();
// Dispatch from anywhere like normal.
store.dispatch(push('/foo'));
store.dispatch(replace('/foo'));
store.dispatch(go(1));
store.dispatch(goForward());
store.dispatch(goBack());
store.dispatch(routerActions.push('/foo'));
store.dispatch(routerActions.replace('/foo'));
开发者ID:ArtemZag,项目名称:DefinitelyTyped,代码行数:32,代码来源:react-router-redux-tests.ts
示例6: createStore
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { routing, appRoutingProviders } from 'src/app/app.routes';
import { AppComponent } from './app/app.component';
import { HomeComponent } from './app/views/home.component';
import { CreatePlayersComponent } from './app/views/create-players.component';
import { StartGameComponent } from './app/views/start-game.component';
import { PlayersPresentationComponent } from './app/views/players-presentation.component';
import {createStore} from 'redux';
import { killersReducer } from 'src/app/reducers/killersReducer';
const appStore = createStore(killersReducer);
import {
AddKillerFormComponent ,
DisplayPlayerComponent,
KillerComponent,
KillersBoardComponent,
KillersListComponent,
KillersListGameComponent,
UserAvatarComponent
} from 'src/app/components';
@NgModule({
imports: [
BrowserModule,
FormsModule,
routing
],
开发者ID:moyesh,项目名称:killer-game-web-ng2,代码行数:31,代码来源:app.module.ts
示例7: createStore
import { reducers } from '../reducers';
import { createStore, compose, applyMiddleware } from 'redux';
import reduxThunk from 'redux-thunk';
export const store = createStore(
reducers,
compose(
applyMiddleware(reduxThunk),
/* tslint:disable-next-line */
window["devToolsExtension"] ? window["devToolsExtension"]() : (f) => f,
),
);
开发者ID:MasterLemon2016,项目名称:LeanMood,代码行数:12,代码来源:index.ts
示例8: configureStore
export function configureStore() {
return createStore(rootReducer, defaultState, applyMiddleware(thunk['withExtraArgument'](api)));
}
开发者ID:get-focus,项目名称:focus-help-center,代码行数:3,代码来源:index.ts
示例9: 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));
};
开发者ID:arborQ,项目名称:TypeGetInvolved,代码行数:29,代码来源:index.ts
示例10: it
it('does not broadcast queries when non-apollo actions are dispatched', (done) => {
const query = gql`
query fetchLuke($id: String) {
people_one(id: $id) {
name
}
}
`;
const variables = {
id: '1',
};
const data1 = {
people_one: {
name: 'Luke Skywalker',
},
};
const data2 = {
people_one: {
name: 'Luke Skywalker has a new name',
},
};
const networkInterface = mockNetworkInterface(
{
request: { query, variables },
result: { data: data1 },
},
{
request: { query, variables },
result: { data: data2 },
}
);
function testReducer (state = false, action) {
if (action.type === 'TOGGLE') {
return true;
}
return state;
}
const client = new ApolloClient();
const store = createStore(
combineReducers({
test: testReducer,
apollo: client.reducer(),
}),
applyMiddleware(client.middleware())
);
const queryManager = new QueryManager({
networkInterface,
store: store,
reduxRootKey: 'apollo',
});
const handle = queryManager.watchQuery({
query,
variables,
});
let handleCount = 0;
const subscription = handle.subscribe({
next(result) {
handleCount++;
if (handleCount === 1) {
assert.deepEqual(result.data, data1);
return subscription.refetch();
} else if (handleCount === 2) {
assert.deepEqual(result.data, data2);
store.dispatch({
type: 'TOGGLE',
});
}
assert.equal(handleCount, 2);
done();
},
});
});
开发者ID:Aweary,项目名称:apollo-client,代码行数:81,代码来源:QueryManager.ts
注:本文中的redux.createStore函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论