本文整理汇总了TypeScript中common/types.Store.dispatch方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Store.dispatch方法的具体用法?TypeScript Store.dispatch怎么用?TypeScript Store.dispatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common/types.Store
的用法示例。
在下文中一共展示了Store.dispatch方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: onMessage
private onMessage(logger: Logger, msg: ISM) {
if (msg.type === "no-update-available") {
this.stage("idle");
} else if (msg.type === "installing-update") {
this.stage("download");
} else if (msg.type === "update-failed") {
const pp = msg.payload as ISM_UpdateFailed;
logger.error(`Self-update failed: ${pp.message}`);
} else if (msg.type === "update-ready") {
const pp = msg.payload as ISM_UpdateReady;
logger.info(`Version ${pp.version} is ready to be used.`);
this.store.dispatch(
actions.packageNeedRestart({
name: this.name,
availableVersion: pp.version,
})
);
} else if (msg.type === "progress") {
const pp = msg.payload as ISM_Progress;
this.store.dispatch(
actions.packageProgress({
name: this.name,
progressInfo: pp,
})
);
} else if (msg.type === "log") {
const pp = msg.payload as ISM_Log;
logger.info(`> ${pp.message}`);
}
}
示例2: dispatchUpdateNotification
function dispatchUpdateNotification(
store: Store,
cave: Cave,
result: CheckUpdateResult
) {
if (!result) {
return;
}
if (!isEmpty(result.warnings)) {
store.dispatch(
actions.statusMessage({
message: [
"status.game_update.check_failed",
{ err: result.warnings[0] },
],
})
);
return;
}
if (isEmpty(result.updates)) {
store.dispatch(
actions.statusMessage({
message: ["status.game_update.not_found", { title: cave.game.title }],
})
);
} else {
store.dispatch(
actions.statusMessage({
message: ["status.game_update.found", { title: cave.game.title }],
})
);
}
}
示例3: if
(ev: Electron.Event, input: Electron.Input) => {
if (input.type === "keyUp") {
if (input.key === "Enter") {
store.dispatch(actions.commandOk({ wind }));
} else if (input.key === "Escape") {
store.dispatch(actions.commandBack({ wind }));
}
}
}
示例4: t
nativeWindow.on("close", (e: any) => {
const rs = store.getState();
if (wind === "root") {
const prefs =
rs.preferences || ({ closeToTray: true } as PreferencesState);
let { closeToTray } = prefs;
if (rs.system.macos) {
closeToTray = true;
}
if (env.integrationTests) {
// always let app close in testing
closeToTray = false;
}
if (store.getState().system.quitting) {
logger.debug("On window.close: quitting, letting it close");
return;
}
if (closeToTray) {
logger.debug("On window.close: close to tray enabled");
} else {
logger.debug("On window.close: close to tray disabled, quitting!");
process.nextTick(() => {
store.dispatch(actions.quit({}));
});
return;
}
// hide, never destroy
e.preventDefault();
nativeWindow.hide();
if (!prefs.gotMinimizeNotification && !store.getState().system.macos) {
store.dispatch(
actions.updatePreferences({
gotMinimizeNotification: true,
})
);
const i18n = store.getState().i18n;
store.dispatch(
actions.notify({
title: t(i18n, ["notification.see_you_soon.title"]),
body: t(i18n, ["notification.see_you_soon.message"]),
})
);
}
} else {
store.dispatch(actions.windClosed({ wind }));
}
});
示例5: async
onCancel: async () => {
store.dispatch(
actions.statusMessage({
message: ["status.installing_game.cancelled", { title: game.title }],
})
);
},
示例6: debounce
const debouncedBounds = debounce(() => {
if (nativeWindow.isDestroyed()) {
return;
}
const windowBounds = nativeWindow.getBounds();
store.dispatch(actions.windBoundsChanged({ wind, bounds: windowBounds }));
}, 2000);
示例7: doAsync
doAsync(async () => {
try {
const dkIdString = details.responseHeaders["X-Itch-Download-Key-Id"];
const pIdString =
details.responseHeaders["X-Itch-Download-Key-Owner-Id"];
if (dkIdString && pIdString) {
const downloadKeyId = parseInt(dkIdString, 10);
const profileId = parseInt(pIdString, 10);
const { downloadKeys } = store.getState().commons;
logger.info(
`Visiting download key page, has key ${downloadKeyId} (owner ${profileId})`
);
if (!downloadKeys[downloadKeyId]) {
logger.info(`That's a new key, fetching...`);
await mcall(messages.FetchDownloadKey, {
downloadKeyId,
profileId,
});
store.dispatch(actions.ownedKeysFetched({}));
}
}
} catch (e) {
logger.warn(`While sniffing headers: ${e.stack}`);
}
});
示例8: commitLocale
function commitLocale(store: Store, lang: string, resourcesIn: I18nKeys) {
const resources: I18nKeys = {};
for (const key of Object.keys(resourcesIn)) {
const value = resourcesIn[key];
resources[key] = value.replace(/{{/g, "{").replace(/}}/g, "}");
}
store.dispatch(actions.localeDownloadEnded({ lang, resources }));
}
示例9: instead
(ev, url, frameName, disposition, options, additionalFeatures) => {
ev.preventDefault();
logger.debug(
`new-window fired for ${url}, navigating instead (in wind ${wind})`
);
const background = disposition === "background-tab";
store.dispatch(actions.navigate({ url, wind, background }));
}
示例10: rescheduleComponentsUpdate
function rescheduleComponentsUpdate(store: Store) {
const sleepTime = UPDATE_INTERVAL + Math.random() + UPDATE_INTERVAL_WIGGLE;
store.dispatch(
actions.scheduleSystemTask({
nextComponentsUpdateCheck: Date.now() + sleepTime,
})
);
}