本文整理汇总了TypeScript中common/types.IStore.dispatch方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IStore.dispatch方法的具体用法?TypeScript IStore.dispatch怎么用?TypeScript IStore.dispatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common/types.IStore
的用法示例。
在下文中一共展示了IStore.dispatch方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: dispatchUpdateNotification
function dispatchUpdateNotification(
store: IStore,
item: CheckUpdateItem,
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: item.game.title }],
})
);
} else {
store.dispatch(
actions.statusMessage({
message: ["status.game_update.found", { title: item.game.title }],
})
);
}
}
示例2: restoreTabs
export async function restoreTabs(store: IStore, profile: Profile) {
const profileId = profile.id;
const { value, ok } = await call(messages.ProfileDataGet, {
profileId,
key: "@itch/tabs",
});
if (!ok) {
logger.info(`No tabs to restore`);
return;
}
try {
const snapshot = JSON.parse(value) as Snapshot;
if (!store.getState().preferences.enableTabs) {
if (snapshot.items.length > 1) {
snapshot.items = [snapshot.items[0]];
}
}
const validTabs = new Set(snapshot.items.map(x => x.id));
if (validTabs.has(snapshot.current)) {
store.dispatch(actions.tabsRestored(snapshot));
} else {
// nevermind
}
} catch (e) {
logger.warn(`Could not retrieve saved tabs: ${e.message}`);
return;
}
}
示例3: refreshButlerd
async function refreshButlerd(store: IStore) {
logger.info(`Refreshing butlerd! Spinning up new instance...`);
let instance = await makeButlerInstance();
instance.promise().catch(e => {
console.error(`butlerd instance threw:`);
console.error(e.stack);
refreshButlerd(store).catch(() => {});
});
const endpoint = await instance.getEndpoint();
logger.info(`Connecting client...`);
const nextClient = new Client(endpoint);
await nextClient.connect();
if (masterClient) {
// instances exit gracefully when all clients have closed
logger.info(`Closing old master client...`);
masterClient.close();
masterClient = null;
}
masterClient = nextClient;
logger.info(`Got new endpoint`);
store.dispatch(actions.gotButlerdEndpoint({ endpoint }));
initialButlerdResolve();
}
示例4:
nativeWindow.on("leave-full-screen", e => {
const ns = store.getState().windows[window].native;
if (ns.fullscreen) {
store.dispatch(
actions.windowFullscreenChanged({ window, fullscreen: false })
);
}
});
示例5: commitLocale
function commitLocale(store: IStore, lang: string, resourcesIn: II18nKeys) {
const resources: II18nKeys = {};
for (const key of Object.keys(resourcesIn)) {
const value = resourcesIn[key];
resources[key] = value.replace(/{{/g, "{").replace(/}}/g, "}");
}
store.dispatch(actions.localeDownloadEnded({ lang, resources }));
}
示例6: rescheduleComponentsUpdate
function rescheduleComponentsUpdate(store: IStore) {
const sleepTime = UPDATE_INTERVAL + Math.random() + UPDATE_INTERVAL_WIGGLE;
store.dispatch(
actions.scheduleSystemTask({
nextComponentsUpdateCheck: Date.now() + sleepTime,
})
);
}
示例7: t
nativeWindow.on("close", (e: any) => {
const prefs = store.getState().preferences || { closeToTray: true };
let { closeToTray } = prefs;
if (env.integrationTests) {
// always let app close in testing
closeToTray = false;
}
if (closeToTray) {
logger.debug("Close to tray enabled");
} else {
logger.debug("Close to tray disabled, quitting!");
process.nextTick(() => {
store.dispatch(actions.quit({}));
});
return;
}
if (!nativeWindow.isVisible()) {
logger.info("Main window hidden, letting it close");
return;
}
if (!prefs.gotMinimizeNotification) {
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"]),
})
);
}
// hide, never destroy
e.preventDefault();
logger.info("Hiding main window");
nativeWindow.hide();
});
示例8: async
async ({ download, progress, speedHistory }) => {
store.dispatch(
actions.downloadProgress({
download,
progress,
speedHistory,
})
);
}