本文整理汇总了TypeScript中common/util/watcher.Watcher类的典型用法代码示例。如果您正苦于以下问题:TypeScript Watcher类的具体用法?TypeScript Watcher怎么用?TypeScript Watcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Watcher类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: function
export default function(watcher: Watcher) {
watcher.on(actions.manageCave, async (store, action) => {
const { caveId } = action.payload;
const { cave } = await mcall(messages.FetchCave, {
caveId,
});
const widgetParams = {
cave,
};
const { game, upload } = cave;
const openModal = actions.openModal(
modals.manageCave.make({
wind: "root",
title: `${game.title} - ${formatUploadTitle(upload)}`,
message: "",
widgetParams,
})
);
store.dispatch(openModal);
});
}
开发者ID:itchio,项目名称:itch,代码行数:25,代码来源:manage-cave.ts
示例2: function
export default function(watcher: Watcher) {
watcher.on(actions.clearBrowsingDataRequest, async (store, action) => {
const { wind } = action.payload;
const response = await promisedModal(
store,
modals.clearBrowsingData.make({
wind,
title: ["preferences.advanced.clear_browsing_data"],
message: "",
buttons: [
{
label: ["prompt.clear_browsing_data.clear"],
id: "modal-clear-data",
action: "widgetResponse",
},
"cancel",
],
widgetParams: {},
})
);
if (!response) {
// modal was closed
return;
}
store.dispatch(
actions.clearBrowsingData({
cache: response.cache,
cookies: response.cookies,
})
);
});
}
开发者ID:itchio,项目名称:itch,代码行数:34,代码来源:clear-browsing-data.ts
示例3: function
export default function(watcher: Watcher) {
watcher.on(actions.boot, async (store, action) => {
await initialSetup(store, { retry: false });
});
watcher.on(actions.retrySetup, async (store, action) => {
await initialSetup(store, { retry: true });
});
watcher.on(actions.packageGotVersionPrefix, async (store, action) => {
const { name } = action.payload;
if (name === "butler") {
await refreshButlerd(store);
}
});
}
开发者ID:HorrerGames,项目名称:itch,代码行数:16,代码来源:setup.ts
示例4: function
export default function(watcher: Watcher) {
watcher.on(actions.showDownloadError, async (store, action) => {
const { id } = action.payload;
const { downloads } = store.getState();
const item = downloads.items[id];
if (!item) {
logger.warn(
`can't show download error for item we don't know about! (${id})`
);
return;
}
const operateLogPath = join(item.stagingFolder, "operate-log.json");
let log = "<missing log>";
try {
log = await sf.readFile(operateLogPath, { encoding: "utf8" });
} catch (e) {
logger.warn(`could not read log: ${e.stack}`);
}
await showInstallErrorModal({
store,
e: getDownloadError(item),
log,
game: item.game,
retryAction: () => actions.retryDownload({ id }),
stopAction: () => actions.discardDownload({ id }),
});
});
}
开发者ID:itchio,项目名称:itch,代码行数:31,代码来源:show-download-error.ts
示例5: function
export default function(watcher: Watcher) {
watcher.on(actions.viewCaveDetails, async (store, action) => {
const { caveId } = action.payload;
const { cave } = await mcall(messages.FetchCave, { caveId });
store.dispatch(
actions.openModal(
modals.exploreJson.make({
wind: "root",
title: `Cave details for ${cave.game ? cave.game.title : "?"}`,
message: "Local cave data:",
widgetParams: {
data: cave,
},
buttons: [
{
label: ["prompt.action.ok"],
},
],
})
)
);
});
}
开发者ID:itchio,项目名称:itch,代码行数:25,代码来源:view-cave-details.ts
示例6: function
export default function(watcher: Watcher) {
watcher.on(actions.gameUpdateAvailable, async (store, action) => {
const { manualGameUpdates = false } = store.getState().preferences;
if (manualGameUpdates) {
// update will appear as main action
return;
}
const { update } = action.payload;
if (!update.direct) {
// update will appear as main action
return;
}
store.dispatch(
actions.queueGameUpdate({ update, choice: update.choices[0] })
);
});
watcher.on(actions.queueGameUpdate, async (store, action) => {
const { update, choice } = action.payload;
const { game } = update;
const { upload, build } = choice;
await mcall(messages.InstallQueue, {
caveId: update.caveId,
game,
upload,
build,
reason: DownloadReason.Update,
queueDownload: true,
});
store.dispatch(actions.downloadQueued({}));
});
watcher.on(actions.queueAllGameUpdates, async (store, action) => {
const { updates } = store.getState().gameUpdates;
for (const update of Object.values(updates)) {
if (update.direct) {
store.dispatch(
actions.queueGameUpdate({ update, choice: update.choices[0] })
);
}
}
});
}
开发者ID:piak2018,项目名称:itch,代码行数:47,代码来源:game-updates.ts
示例7: function
export default function(watcher: Watcher) {
watcher.on(actions.boot, async (store, action) => {
// load initial locales
const configPayload = await readFile(localesConfigPath);
const config = JSON.parse(configPayload);
store.dispatch(actions.localesConfigLoaded(config));
await loadLocale(store, "en");
});
watcher.onDebounced(
actions.queueLocaleDownload,
2000,
async (store, action) => {
let { lang, implicit } = action.payload;
const downloading = store.getState().i18n.downloading;
if (downloading[lang]) {
return;
}
store.dispatch(actions.localeDownloadStarted({ lang }));
let resources = {};
try {
resources = await doDownloadLocale(lang, resources, { implicit });
} catch (e) {
logger.warn(`Failed downloading locale for ${lang}: ${e.message}`);
} finally {
commitLocale(store, lang, resources);
}
}
);
watcher.on(actions.languageChanged, async (store, action) => {
const { lang } = action.payload;
await loadLocale(store, lang);
});
watcher.on(actions.reloadLocales, async (store, action) => {
const { lang } = store.getState().i18n;
logger.info(`Reloading locales...`);
await loadLocale(store, lang);
});
}
开发者ID:itchio,项目名称:itch,代码行数:47,代码来源:locales.ts
示例8: function
export default function(watcher: Watcher) {
watcher.onDebounced(
actions.tabsChanged,
tabAutoSaveThreshold,
async (store, action) => {
await saveTabs(store);
}
);
}
开发者ID:HorrerGames,项目名称:itch,代码行数:9,代码来源:tab-save.ts
示例9: function
export default function(watcher: Watcher) {
watcher.on(actions.initiatePurchase, async (store, action) => {
const { game } = action.payload;
const purchaseUrl = game.url + "/purchase";
const loginPurchaseUrl = buildLoginAndReturnUrl(purchaseUrl);
store.dispatch(actions.navigate({ wind: "root", url: loginPurchaseUrl }));
});
}
开发者ID:itchio,项目名称:itch,代码行数:9,代码来源:purchases.ts
示例10: function
export default function(watcher: Watcher) {
watcher.on(actions.probeCave, async (store, action) => {
const { caveId } = action.payload;
const caveLogPath = paths.caveLogPath(caveId);
logger.info(`Opening cave log path ${caveLogPath}`);
shell.openItem(caveLogPath);
});
}
开发者ID:HorrerGames,项目名称:itch,代码行数:9,代码来源:probe-cave.ts
注:本文中的common/util/watcher.Watcher类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论