本文整理匯總了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;
}
示例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({