当前位置: 首页>>代码示例>>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;未经允许,请勿转载。