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


TypeScript IStore.dispatch方法代码示例

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


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

示例1: dispatchUpdateNotification

function dispatchUpdateNotification(
  store: IStore,
  item: CheckUpdateItem,
  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: item.game.title }],
      })
    );
  } else {
    store.dispatch(
      actions.statusMessage({
        message: ["status.game_update.found", { title: item.game.title }],
      })
    );
  }
}
开发者ID:HorrerGames,项目名称:itch,代码行数:35,代码来源:updater.ts

示例2: restoreTabs

export async function restoreTabs(store: IStore, profile: Profile) {
  const profileId = profile.id;

  const { value, ok } = await call(messages.ProfileDataGet, {
    profileId,
    key: "@itch/tabs",
  });

  if (!ok) {
    logger.info(`No tabs to restore`);
    return;
  }

  try {
    const snapshot = JSON.parse(value) as Snapshot;
    if (!store.getState().preferences.enableTabs) {
      if (snapshot.items.length > 1) {
        snapshot.items = [snapshot.items[0]];
      }
    }

    const validTabs = new Set(snapshot.items.map(x => x.id));
    if (validTabs.has(snapshot.current)) {
      store.dispatch(actions.tabsRestored(snapshot));
    } else {
      // nevermind
    }
  } catch (e) {
    logger.warn(`Could not retrieve saved tabs: ${e.message}`);
    return;
  }
}
开发者ID:HorrerGames,项目名称:itch,代码行数:32,代码来源:tab-save.ts

示例3: refreshButlerd

async function refreshButlerd(store: IStore) {
  logger.info(`Refreshing butlerd! Spinning up new instance...`);
  let instance = await makeButlerInstance();
  instance.promise().catch(e => {
    console.error(`butlerd instance threw:`);
    console.error(e.stack);
    refreshButlerd(store).catch(() => {});
  });
  const endpoint = await instance.getEndpoint();

  logger.info(`Connecting client...`);
  const nextClient = new Client(endpoint);
  await nextClient.connect();

  if (masterClient) {
    // instances exit gracefully when all clients have closed
    logger.info(`Closing old master client...`);
    masterClient.close();
    masterClient = null;
  }
  masterClient = nextClient;
  logger.info(`Got new endpoint`);
  store.dispatch(actions.gotButlerdEndpoint({ endpoint }));
  initialButlerdResolve();
}
开发者ID:HorrerGames,项目名称:itch,代码行数:25,代码来源:setup.ts

示例4:

 nativeWindow.on("leave-full-screen", e => {
   const ns = store.getState().windows[window].native;
   if (ns.fullscreen) {
     store.dispatch(
       actions.windowFullscreenChanged({ window, fullscreen: false })
     );
   }
 });
开发者ID:HorrerGames,项目名称:itch,代码行数:8,代码来源:main-window.ts

示例5: commitLocale

function commitLocale(store: IStore, lang: string, resourcesIn: II18nKeys) {
  const resources: II18nKeys = {};
  for (const key of Object.keys(resourcesIn)) {
    const value = resourcesIn[key];
    resources[key] = value.replace(/{{/g, "{").replace(/}}/g, "}");
  }
  store.dispatch(actions.localeDownloadEnded({ lang, resources }));
}
开发者ID:HorrerGames,项目名称:itch,代码行数:8,代码来源:locales.ts

示例6: rescheduleComponentsUpdate

function rescheduleComponentsUpdate(store: IStore) {
  const sleepTime = UPDATE_INTERVAL + Math.random() + UPDATE_INTERVAL_WIGGLE;
  store.dispatch(
    actions.scheduleSystemTask({
      nextComponentsUpdateCheck: Date.now() + sleepTime,
    })
  );
}
开发者ID:HorrerGames,项目名称:itch,代码行数:8,代码来源:self-update.ts

示例7: t

  nativeWindow.on("close", (e: any) => {
    const prefs = store.getState().preferences || { closeToTray: true };

    let { closeToTray } = prefs;
    if (env.integrationTests) {
      // always let app close in testing
      closeToTray = false;
    }

    if (closeToTray) {
      logger.debug("Close to tray enabled");
    } else {
      logger.debug("Close to tray disabled, quitting!");
      process.nextTick(() => {
        store.dispatch(actions.quit({}));
      });
      return;
    }

    if (!nativeWindow.isVisible()) {
      logger.info("Main window hidden, letting it close");
      return;
    }

    if (!prefs.gotMinimizeNotification) {
      store.dispatch(
        actions.updatePreferences({
          gotMinimizeNotification: true,
        })
      );

      const i18n = store.getState().i18n;
      store.dispatch(
        actions.notify({
          title: t(i18n, ["notification.see_you_soon.title"]),
          body: t(i18n, ["notification.see_you_soon.message"]),
        })
      );
    }

    // hide, never destroy
    e.preventDefault();
    logger.info("Hiding main window");
    nativeWindow.hide();
  });
开发者ID:HorrerGames,项目名称:itch,代码行数:45,代码来源:main-window.ts

示例8: async

 async ({ download, progress, speedHistory }) => {
   store.dispatch(
     actions.downloadProgress({
       download,
       progress,
       speedHistory,
     })
   );
 }
开发者ID:HorrerGames,项目名称:itch,代码行数:9,代码来源:driver.ts


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