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


TypeScript util.uuid函數代碼示例

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


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

示例1: getRendererId

// Renderer ID is remembered to avoid announcing a new renderer when reloading
// the renderer window. Note that each tab has creates a new session and thus
// a new rendererId.
// https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
function getRendererId(): RendererId {
  let rId = sessionStorage.getItem('cosmosRendererId');

  if (!rId) {
    rId = uuid();
    sessionStorage.setItem('cosmosRendererId', rId);
  }

  return rId;
}
開發者ID:skidding,項目名稱:cosmos,代碼行數:14,代碼來源:rendererId.ts

示例2: uuid

import { uuid } from 'react-cosmos-shared2/util';
import retry from '@skidding/async-retry';
import { runFixtureLoaderTests } from '../testHelpers';

const rendererId = uuid();
const fixtures = { first: 'First' };
const decorators = {};
const fixtureId = { path: 'first', name: null };

runFixtureLoaderTests(mount => {
  it('fires change callback when selecting fixture', async () => {
    const onFixtureChange = jest.fn();
    await mount(
      { rendererId, fixtures, decorators, onFixtureChange },
      async ({ selectFixture }) => {
        await selectFixture({
          rendererId,
          fixtureId,
          fixtureState: {}
        });
        await retry(() => expect(onFixtureChange).toBeCalledTimes(1));
      }
    );
  });

  it('fires change callback when unselecting fixture', async () => {
    const onFixtureChange = jest.fn();
    await mount(
      { rendererId, fixtures, decorators, onFixtureChange },
      async ({ selectFixture, unselectFixture }) => {
        await selectFixture({
開發者ID:skidding,項目名稱:cosmos,代碼行數:31,代碼來源:changeCallback.ts


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