当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript types.Store类代码示例

本文整理汇总了TypeScript中common/types.Store的典型用法代码示例。如果您正苦于以下问题:TypeScript Store类的具体用法?TypeScript Store怎么用?TypeScript Store使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Store类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: dispatchUpdateNotification

function dispatchUpdateNotification(
  store: Store,
  cave: Cave,
  result: CheckUpdateResult
) {
  if (!result) {
    return;
  }

  if (!isEmpty(result.warnings)) {
    store.dispatch(
      actions.statusMessage({
        message: [
          "status.game_update.check_failed",
          { err: result.warnings[0] },
        ],
      })
    );
    return;
  }

  if (isEmpty(result.updates)) {
    store.dispatch(
      actions.statusMessage({
        message: ["status.game_update.not_found", { title: cave.game.title }],
      })
    );
  } else {
    store.dispatch(
      actions.statusMessage({
        message: ["status.game_update.found", { title: cave.game.title }],
      })
    );
  }
}
开发者ID:itchio,项目名称:itch,代码行数:35,代码来源:updater.ts

示例2: applyTabOffset

async function applyTabOffset(store: Store, wind: string, offset: number) {
  const { tab, openTabs } = store.getState().winds[wind].navigation;

  const numTabs = openTabs.length;
  const index = openTabs.indexOf(tab);

  // adding numPaths takes care of negative wrapping too!
  const newIndex = (index + offset + numTabs) % numTabs;
  const newTab = openTabs[newIndex];

  store.dispatch(actions.tabFocused({ wind, tab: newTab }));
}
开发者ID:itchio,项目名称:itch,代码行数:12,代码来源:tabs.ts

示例3: push

function push(store: Store, next: typeof actions.commonsUpdated.payload) {
  const prev = store.getState().commons;

  let hasDifferences = false;
  for (const k of Object.keys(next)) {
    if (!isEqual((prev as any)[k], (next as any)[k])) {
      hasDifferences = true;
      break;
    }
  }

  if (hasDifferences) {
    store.dispatch(actions.commonsUpdated(next));
  }
}
开发者ID:itchio,项目名称:itch,代码行数:15,代码来源:commons.ts

示例4: syncInstallLocations

async function syncInstallLocations(store: Store) {
  const { installLocations } = await mcall(messages.InstallLocationsList, {});
  const newLocationsById = indexBy(installLocations, "id");

  const { preferences } = store.getState();
  if (!preferences.importedOldInstallLocations) {
    await mkdirp(appdataLocationPath());
    let oldLocations = {
      ...preferences.installLocations,
      appdata: {
        id: "appdata",
        path: appdataLocationPath(),
      },
    } as { [key: string]: { id: string; path: string } };

    let numAdded = 0;
    if (!isEmpty(oldLocations)) {
      for (const id of Object.keys(oldLocations)) {
        logger.debug(`Checking install location ${id}...`);
        const oldLoc = oldLocations[id];
        const newLoc = newLocationsById[id];
        if (newLoc) {
          logger.debug(`Has on butler side too!`);
        } else {
          logger.debug(`Synchronizing ${id}...`);
          numAdded++;
          try {
            await mcall(messages.InstallLocationsAdd, {
              id,
              path: oldLoc.path,
            });
          } catch (e) {
            logger.warn(`Could not add ${oldLoc.path}: ${e.stack}`);
          }
        }
      }
    }

    if (numAdded > 0) {
      logger.info(`Registered ${numAdded} install locations with butler`);
    } else {
      logger.info(`All install locations synchronized with butler`);
    }
    store.dispatch(
      actions.updatePreferences({ importedOldInstallLocations: true })
    );
  }
}
开发者ID:itchio,项目名称:itch,代码行数:48,代码来源:setup.ts

示例5: updateCommonsNowThrows

async function updateCommonsNowThrows(store: Store) {
  if (!store.getState().setup.done) {
    return;
  }

  const { caves, downloadKeys, installLocations } = await mcall(
    messages.FetchCommons,
    {}
  );

  let locationSizes: { [key: string]: number } = {};
  if (!isEmpty(installLocations)) {
    for (const x of installLocations) {
      locationSizes[x.id] = x.sizeInfo.installedSize;
    }
  }

  push(store, {
    caves: indexBy(caves, "id"),
    caveIdsByGameId: groupIdBy(caves, "gameId"),
    downloadKeys: indexBy(downloadKeys, "id"),
    downloadKeyIdsByGameId: groupIdBy(downloadKeys, "gameId"),
    locationSizes,
  });
}
开发者ID:itchio,项目名称:itch,代码行数:25,代码来源:commons.ts

示例6: mcall

      doAsync(async () => {
        try {
          const dkIdString = details.responseHeaders["X-Itch-Download-Key-Id"];
          const pIdString =
            details.responseHeaders["X-Itch-Download-Key-Owner-Id"];
          if (dkIdString && pIdString) {
            const downloadKeyId = parseInt(dkIdString, 10);
            const profileId = parseInt(pIdString, 10);
            const { downloadKeys } = store.getState().commons;

            logger.info(
              `Visiting download key page, has key ${downloadKeyId} (owner ${profileId})`
            );

            if (!downloadKeys[downloadKeyId]) {
              logger.info(`That's a new key, fetching...`);
              await mcall(messages.FetchDownloadKey, {
                downloadKeyId,
                profileId,
              });
              store.dispatch(actions.ownedKeysFetched({}));
            }
          }
        } catch (e) {
          logger.warn(`While sniffing headers: ${e.stack}`);
        }
      });
开发者ID:itchio,项目名称:itch,代码行数:27,代码来源:register-itch-protocol.ts

示例7: onMessage

 private onMessage(logger: Logger, msg: ISM) {
   if (msg.type === "no-update-available") {
     this.stage("idle");
   } else if (msg.type === "installing-update") {
     this.stage("download");
   } else if (msg.type === "update-failed") {
     const pp = msg.payload as ISM_UpdateFailed;
     logger.error(`Self-update failed: ${pp.message}`);
   } else if (msg.type === "update-ready") {
     const pp = msg.payload as ISM_UpdateReady;
     logger.info(`Version ${pp.version} is ready to be used.`);
     this.store.dispatch(
       actions.packageNeedRestart({
         name: this.name,
         availableVersion: pp.version,
       })
     );
   } else if (msg.type === "progress") {
     const pp = msg.payload as ISM_Progress;
     this.store.dispatch(
       actions.packageProgress({
         name: this.name,
         progressInfo: pp,
       })
     );
   } else if (msg.type === "log") {
     const pp = msg.payload as ISM_Log;
     logger.info(`> ${pp.message}`);
   }
 }
开发者ID:itchio,项目名称:itch,代码行数:30,代码来源:self-package.ts

示例8: if

 (ev: Electron.Event, input: Electron.Input) => {
   if (input.type === "keyUp") {
     if (input.key === "Enter") {
       store.dispatch(actions.commandOk({ wind }));
     } else if (input.key === "Escape") {
       store.dispatch(actions.commandBack({ wind }));
     }
   }
 }
开发者ID:itchio,项目名称:itch,代码行数:9,代码来源:winds.ts

示例9: ensure

 async ensure(opts: EnsureOpts) {
   const rs = this.store.getState();
   this.store.dispatch(
     actions.packageGotVersionPrefix({
       name: this.name,
       version: rs.system.appVersion,
       versionPrefix: rs.system.userDataPath,
     })
   );
 }
开发者ID:itchio,项目名称:itch,代码行数:10,代码来源:self-package.ts

示例10: async

 onCancel: async () => {
   store.dispatch(
     actions.statusMessage({
       message: ["status.installing_game.cancelled", { title: game.title }],
     })
   );
 },
开发者ID:itchio,项目名称:itch,代码行数:7,代码来源:queue-game.ts


注:本文中的common/types.Store类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。