本文整理匯總了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']
});
});