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


TypeScript actions.newItemsImported方法代碼示例

本文整理匯總了TypeScript中common/actions.actions.newItemsImported方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript actions.newItemsImported方法的具體用法?TypeScript actions.newItemsImported怎麽用?TypeScript actions.newItemsImported使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在common/actions.actions的用法示例。


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

示例1: async

 watcher.on(actions.silentlyScanInstallLocations, async (store, action) => {
   try {
     logger.info(`Scanning install locations for items...`);
     await mcall(
       messages.InstallLocationsScan,
       {
         legacyMarketPath: legacyMarketPath(),
       },
       convo => {
         hookLogging(convo, logger);
         convo.on(messages.Progress, async ({ progress }) => {
           store.dispatch(actions.locationScanProgress({ progress }));
         });
         convo.on(messages.InstallLocationsScanYield, async ({ game }) => {
           logger.info(`Found ${game.title} - ${game.url}`);
         });
         convo.on(
           messages.InstallLocationsScanConfirmImport,
           async ({ numItems }) => {
             logger.info(`In total, found ${numItems} items.`);
             return { confirm: true };
           }
         );
       }
     );
     logger.info(`Scan complete.`);
     store.dispatch(actions.newItemsImported({}));
   } finally {
     store.dispatch(actions.locationScanDone({}));
   }
 });
開發者ID:itchio,項目名稱:itch,代碼行數:31,代碼來源:silent-location-scan.ts

示例2: 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/actions.actions.newItemsImported方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。