本文整理汇总了TypeScript中redux.Store.dispatch方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Store.dispatch方法的具体用法?TypeScript Store.dispatch怎么用?TypeScript Store.dispatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redux.Store
的用法示例。
在下文中一共展示了Store.dispatch方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: doCorked
export function doCorked(store: Store<any>, func: () => void) {
try {
store.dispatch(actions.cork())
func()
} finally {
store.dispatch(actions.uncork())
}
}
示例2: it
it("should return false if no data is missing", function () {
store.dispatch(clusterReducerObj.receiveData(new protos.cockroach.server.serverpb.ClusterResponse({cluster_id: CLUSTER_ID})));
store.dispatch(setUIDataKey(KEY_HELPUS, {}));
store.dispatch(setUIDataKey(KEY_REGISTRATION_SYNCHRONIZED, true));
assert.isFalse(registrationService.shouldLoadKeys(store.getState()));
assert.isFalse(registrationService.shouldLoadClusterInfo(store.getState()));
assert.isFalse(registrationService.shouldLoadData(store.getState()));
});
示例3: configureStore
const createStore = (currentUser?: T.CurrentUser, appState?: T.AppState) => {
store = configureStore(rootReducer);
if (currentUser) {
store.dispatch(receiveCurrentUser(currentUser));
}
if (appState) {
store.dispatch(setAppState(appState));
}
return store;
};
示例4: it
it('should call the load function with only the series IDs that have requested loads', () => {
store.dispatch({
type: ActionType.DATA_REQUESTED,
payload: [ SERIES_A ]
});
store.dispatch(_performDataLoad());
dataLoaderSpy.calledOnce.should.be.true();
dataLoaderSpy.firstCall.args[0].should.deepEqual([ SERIES_A ]);
});
示例5: switch
.map(message => {
// This is a bit of a hack and we're stretching the limits of a faux
// chat app. Every time there is a new message, we only want to keep the
// new ones. This is a case where some sort of queue would be a better
// model
if (handledMessages.hasOwnProperty(message.id)) {
return;
}
handledMessages[message.id] = true;
switch (message.thread.id) {
case tEcho.id:
// echo back the same message to the user
store.dispatch(ThreadActions.addMessage(tEcho, {
author: echo,
text: message.text
}));
break;
case tRev.id:
// echo back the message reveresed to the user
store.dispatch(ThreadActions.addMessage(tRev, {
author: rev,
text: message.text.split('').reverse().join('')
}));
break;
case tWait.id:
let waitTime: number = parseInt(message.text, 10);
let reply: string;
if (isNaN(waitTime)) {
waitTime = 0;
reply = `I didn\'t understand ${message}. Try sending me a number`;
} else {
reply = `I waited ${waitTime} seconds to send you this.`;
}
setTimeout(
() => {
store.dispatch(ThreadActions.addMessage(tWait, {
author: wait,
text: reply
}));
},
waitTime * 1000);
break;
default:
break;
}
});
示例6: stepForward
function stepForward() {
if (!isPlaying()) {
timeoutId = 0;
return;
}
schedule();
if (canForward()) {
store.dispatch(Actions.playForward());
} else {
store.dispatch(Actions.togglePlayback());
}
}
示例7: handleClose
handleClose() {
console.error('lost ws connection');
this._store.dispatch({
type: 'disconnect',
});
}
示例8: return
return (store: Store<FullState>) => {
const payload = keeps.reduce(
(action, { key, storage, load }) => ({ ...action, [key]: load(key, storage), }),
{}
);
store.dispatch({
payload,
type: HYDRATE
});
const results: { [key: string]: any; } = {};
store.subscribe(() => {
const state = store.getState();
for (const { key, selector, storage, save } of keeps) {
const result = selector(state);
if (result !== results[key]) {
results[key] = result;
save(key, result, storage);
}
}
});
};
示例9: it
it('should handle normal actions by default', () => {
store.dispatch({ type: 'HOLD' });
expect(store.getState()).to.deep.equal({
actions: ['HOLD']
});
});