當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript butlerd.withLogger函數代碼示例

本文整理匯總了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);
        });
      }
    );
  }
開發者ID:HorrerGames,項目名稱:itch,代碼行數:29,代碼來源:dashboard-fetcher.ts

示例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,
      },
    });
  }
開發者ID:HorrerGames,項目名稱:itch,代碼行數:26,代碼來源:location-fetcher.ts

示例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();
          }
        });
      }
    );
  }
開發者ID:HorrerGames,項目名稱:itch,代碼行數:49,代碼來源:library-fetcher.ts

示例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"),
            },
          });
        });
      }
    );
  }
開發者ID:HorrerGames,項目名稱:itch,代碼行數:23,代碼來源:collections-fetcher.ts

示例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);
        });
      }
    );
  }
開發者ID:HorrerGames,項目名稱:itch,代碼行數:36,代碼來源:collection-fetcher.ts

示例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));
    }
  });
}
開發者ID:HorrerGames,項目名稱:itch,代碼行數:27,代碼來源:explore-cave.ts

示例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({}));
}
開發者ID:HorrerGames,項目名稱:itch,代碼行數:91,代碼來源:queue-game.ts


注:本文中的common/butlerd.withLogger函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。