本文整理汇总了TypeScript中common/butlerd.withLogger函数的典型用法代码示例。如果您正苦于以下问题:TypeScript withLogger函数的具体用法?TypeScript withLogger怎么用?TypeScript withLogger使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了withLogger函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: work
async work(): Promise<void> {
// first, filter what we already got
const cachedGames = getByIds(
this.space().games().set,
this.space().games().allIds
);
const dataGamesCount = cachedGames.length;
if (dataGamesCount > 0) {
this.pushUnfilteredGames(cachedGames);
if (!this.warrantsRemote()) {
return;
}
}
const call = withLogger(this.logger);
await call(
messages.FetchProfileGames,
{
profileId: this.profileId(),
},
client => {
client.on(messages.FetchProfileGamesYield, async ({ items }) => {
const games = map(items, i => i.game);
this.pushUnfilteredGames(games);
});
}
);
}
示例2: work
async work(): Promise<void> {
const installLocationId = this.space().firstPathElement();
let call = withLogger(this.logger);
const { caves, installLocationPath, installLocationSize } = await call(
messages.FetchCavesByInstallLocationID,
{ installLocationId }
);
let games: Game[] = [];
if (!isEmpty(caves)) {
for (const c of caves) {
games.push(c.game);
}
games = uniq(games, g => g.id);
}
this.pushUnfilteredGames(games, { disableFilters: true });
this.push({
location: {
path: installLocationPath,
size: installLocationSize,
},
});
}
示例3: work
async work(): Promise<void> {
let call = withLogger(this.logger);
// first, filter what we already got
const cachedGames = getByIds(
this.space().games().set,
this.space().games().allIds
);
const dataGamesCount = cachedGames.length;
if (dataGamesCount > 0) {
this.debug(`Pushing ${dataGamesCount} from cachedGames`);
this.pushUnfilteredGames(cachedGames);
if (!this.warrantsRemote()) {
return;
}
}
let games: Game[] = [];
const push = () => {
games = uniq(games, g => g.id);
this.pushUnfilteredGames(games);
};
const { caves } = await call(messages.FetchCaves, {});
if (caves) {
for (const cave of caves) {
games.push(cave.game);
}
}
await call(
messages.FetchProfileOwnedKeys,
{
profileId: this.profileId(),
},
client => {
client.on(messages.FetchProfileOwnedKeysYield, async ({ items }) => {
if (items) {
for (const dk of items) {
games.push(dk.game);
}
push();
}
});
}
);
}
示例4: work
async work(): Promise<void> {
if (!this.warrantsRemote()) {
return;
}
const call = withLogger(this.logger);
await call(
messages.FetchProfileCollections,
{
profileId: this.profileId(),
},
client => {
client.on(messages.FetchProfileCollectionsYield, async ({ items }) => {
this.push({
collections: {
set: indexBy(items, "id"),
ids: pluck(items, "id"),
},
});
});
}
);
}
示例5: work
async work(): Promise<void> {
// first, filter what we already got
const cachedGames = getByIds(
this.space().games().set,
this.space().games().allIds
);
const dataGamesCount = cachedGames.length;
if (dataGamesCount > 0) {
this.pushUnfilteredGames(cachedGames);
if (!this.warrantsRemote()) {
return;
}
}
const collectionId = this.space().firstPathNumber();
const call = withLogger(this.logger);
await call(
messages.FetchCollection,
{
profileId: this.profileId(),
collectionId,
},
client => {
client.on(messages.FetchCollectionYield, async ({ collection }) => {
const games: Game[] = [];
for (const cg of collection.collectionGames) {
games.push(cg.game);
}
this.pushCollection(collection);
this.pushUnfilteredGames(games);
});
}
);
}
示例6: withLogger
import { Watcher } from "common/util/watcher";
import { actions } from "common/actions";
import fs from "fs";
import { dirname } from "path";
import rootLogger from "common/logger";
const logger = rootLogger.child({ name: "explore-cave" });
import * as explorer from "../../os/explorer";
import { withLogger, messages } from "common/butlerd";
const call = withLogger(logger);
export default function(watcher: Watcher) {
watcher.on(actions.exploreCave, async (store, action) => {
const { caveId } = action.payload;
const { cave } = await call(messages.FetchCave, { caveId });
const installFolder = cave.installInfo.installFolder;
try {
fs.accessSync(installFolder);
explorer.open(installFolder);
} catch (e) {
explorer.open(dirname(installFolder));
}
});
}
示例7: performInstallQueue
async function performInstallQueue({
store,
logger,
game,
upload,
build,
}: {
store: IStore;
logger: Logger;
game: Game;
upload: Upload;
build: Build;
}) {
const installLocationId = defaultInstallLocation(store);
await withLogger(logger)(
messages.InstallQueue,
{
game,
upload,
build,
installLocationId,
queueDownload: true,
},
client => {
client.on(messages.PickUpload, async ({ uploads }) => {
const { title } = game;
const modalRes = await promisedModal(
store,
modalWidgets.pickUpload.make({
window: "root",
title: ["pick_install_upload.title", { title }],
message: ["pick_install_upload.message", { title }],
coverUrl: game.coverUrl,
stillCoverUrl: game.stillCoverUrl,
bigButtons: map(uploads, (candidate, index) => {
return {
...makeUploadButton(candidate),
action: modalWidgets.pickUpload.action({
pickedUploadIndex: index,
}),
};
}),
buttons: ["cancel"],
widgetParams: {},
})
);
if (modalRes) {
return { index: modalRes.pickedUploadIndex };
} else {
// that tells butler to abort
return { index: -1 };
}
});
client.on(messages.ExternalUploadsAreBad, async () => {
const modalRes = await promisedModal(
store,
modalWidgets.naked.make({
window: "root",
title: "Dragons be thar",
message:
"You've chosen to install an external upload. Those are supported poorly.",
detail:
"There's a chance it won't install at all.\n\nAlso, we won't be able to check for updates.",
bigButtons: [
{
label: "Install it anyway",
tags: [{ label: "Consequences be damned" }],
icon: "fire",
action: actions.modalResponse({}),
},
"nevermind",
],
widgetParams: null,
})
);
if (!modalRes) {
return { whatever: false };
}
// ahh damn.
return { whatever: true };
});
}
);
store.dispatch(actions.downloadQueued({}));
}