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


TypeScript butlerd.call函數代碼示例

本文整理匯總了TypeScript中common/butlerd.call函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript call函數的具體用法?TypeScript call怎麽用?TypeScript call使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了call函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: async

  watcher.on(actions.addInstallLocation, async (store, action) => {
    const { window } = action.payload;
    const i18n = store.getState().i18n;
    const nativeWindow = getNativeWindow(store.getState(), window);
    if (!nativeWindow) {
      return;
    }

    const dialogOpts = {
      title: t(i18n, ["prompt.install_location_add.title"]),
      // crazy typescript workaround, avert your eyes
      properties: ["openDirectory", "createDirectory"] as (
        | "openDirectory"
        | "createDirectory")[],
    };

    const promise = new ItchPromise<string>((resolve, reject) => {
      const callback = (response: string[]) => {
        if (!response) {
          return resolve();
        }

        return resolve(response[0]);
      };
      dialog.showOpenDialog(nativeWindow, dialogOpts, callback);
    });

    const path = await promise;
    if (path) {
      await call(messages.InstallLocationsAdd, { path });
      store.dispatch(actions.installLocationsChanged({}));
    }
  });
開發者ID:HorrerGames,項目名稱:itch,代碼行數:33,代碼來源:install-locations.ts

示例2: call

export async function mcall<Params, Res>(
  rc: RequestCreator<Params, Res>,
  params: {} & Params,
  setup?: SetupFunc
): Promise<Res> {
  return await call(store, logger, rc, params, setup);
}
開發者ID:itchio,項目名稱:itch,代碼行數:7,代碼來源:mcall.ts

示例3: call

 (async () => {
   try {
     let navigated = false;
     await call(messages.FetchGame, { gameId }, async client => {
       client.onNotification(messages.FetchGameYield, ({ params }) => {
         if (navigated) {
           return;
         }
         navigated = true;
         const { game } = params;
         store.dispatch(
           actions.navigateToGame({ game, window: "root" })
         );
       });
     });
   } catch (e) {
     store.dispatch(
       actions.statusMessage({ message: `Game ${gameId} not found` })
     );
   }
 })().catch(e => {
開發者ID:HorrerGames,項目名稱:itch,代碼行數:21,代碼來源:url.ts

示例4: async

  watcher.on(actions.scanInstallLocations, async (store, action) => {
    let names: string[] = [];
    let widgetParams: IScanInstallLocationsParams = {
      progress: 0.00001,
      game: null,
    };

    const openModal = actions.openModal(
      modalWidgets.scanInstallLocations.make({
        window: "root",
        title: ["preferences.scan_install_locations.title"],
        message: "",
        buttons: [
          {
            label: ["prompt.action.close"],
            className: "secondary",
          },
        ],
        widgetParams,
        unclosable: true,
      })
    );
    store.dispatch(openModal);
    const modalId = openModal.payload.id;

    const update = () => {
      store.dispatch(
        actions.updateModalWidgetParams(
          modalWidgets.scanInstallLocations.update({
            id: modalId,
            widgetParams,
          })
        )
      );
    };

    try {
      const importRes = await call(
        messages.InstallLocationsScan,
        {},
        client => {
          client.onNotification(messages.Progress, async ({ params }) => {
            // TODO: relay ETA too?
            widgetParams.progress = params.progress;
            update();
          });

          client.onNotification(
            messages.InstallLocationsScanYield,
            async ({ params }) => {
              names.push(params.game.title);
              widgetParams.game = params.game;
              update();
            }
          );

          client.onRequest(
            messages.InstallLocationsScanConfirmImport,
            async ({ params }) => {
              const res = await promisedModal(
                store,
                modalWidgets.naked.make({
                  window: "root",
                  title: ["preferences.scan_install_locations.confirm_import"],
                  message: ["preferences.scan_install_locations.message"],
                  detail: names.map(n => `  * ${n}`).join("\n") + "\n",
                  widgetParams: null,
                  buttons: [
                    {
                      label: [
                        "preferences.scan_install_locations.import_items",
                        { numItems: params.numItems },
                      ],
                      icon: "install",
                      action: actions.modalResponse({}),
                    },
                    "cancel",
                  ],
                })
              );
              return { confirm: !!res };
            }
          );
        }
      );

      if (importRes.numFoundItems == 0) {
        store.dispatch(
          actions.statusMessage({
            message: ["preferences.scan_install_locations.no_items_found"],
          })
        );
      } else if (importRes.numImportedItems > 0) {
        store.dispatch(actions.newItemsImported({}));
        store.dispatch(
          actions.statusMessage({
            message: [
              "preferences.scan_install_locations.items_imported",
              { numImportedItems: importRes.numImportedItems },
            ],
//.........這裏部分代碼省略.........
開發者ID:HorrerGames,項目名稱:itch,代碼行數:101,代碼來源:scan-install-locations.ts


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