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


TypeScript types.enumeration方法代码示例

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


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

示例1: switch

export const aclTypeValues = {
  GROUP: { value: 'Group', text: 'Team' },
  USER: { value: 'User', text: 'User' },
  VIEWER: { value: 'Viewer', text: 'Everyone With Viewer Role' },
  EDITOR: { value: 'Editor', text: 'Everyone With Editor Role' },
};

export const aclTypes = Object.keys(aclTypeValues).map(item => aclTypeValues[item]);

const defaultNewType = aclTypes[0].value;

export const NewPermissionsItem = types
  .model('NewPermissionsItem', {
    type: types.optional(
      types.enumeration(Object.keys(aclTypeValues).map(item => aclTypeValues[item].value)),
      defaultNewType
    ),
    userId: types.maybe(types.number),
    userLogin: types.maybe(types.string),
    userAvatarUrl: types.maybe(types.string),
    teamAvatarUrl: types.maybe(types.string),
    teamId: types.maybe(types.number),
    team: types.maybe(types.string),
    permission: types.optional(types.number, 1),
  })
  .views(self => ({
    isValid: () => {
      switch (self.type) {
        case aclTypeValues.GROUP.value:
          return self.teamId && self.team;
开发者ID:zalando-zmon,项目名称:grafana,代码行数:30,代码来源:PermissionsStore.ts

示例2:

import { types } from 'mobx-state-tree';

export const Locale = types.enumeration('Locale', ['ICELANDIC']);
开发者ID:birkir,项目名称:kvikmyndr-app,代码行数:3,代码来源:Locale.ts

示例3:

import { mapMovie } from 'utils/mapMovie';
import { uniqBy } from 'lodash';
import Store from 'store';
import { isSameDay } from 'date-fns/esm';
import { addHours } from 'date-fns';

interface IMovieLocale {
  contentRating?: string;
  title?: string;
  summary?: string;
  alternateTitle?: string;
  releaseDate?: string;
}

export const MovieStatus = types.enumeration('MovieStatus', [
  'RELEASED',
  'POST_PRODUCTION',
]);

export const MovieLocale = types.model('MovieLocale', {
  id: types.identifier,
  locale: Locale,
  contentRating: types.maybeNull(types.string),
  title: types.maybeNull(types.string),
  summary: types.maybeNull(types.string),
  alternateTitle: types.maybeNull(types.string),
  releaseDate: types.maybeNull(types.string),
});

export const Movie = types.model('Movie', {
  id: types.identifier,
  isPartial: types.optional(types.boolean, true),
开发者ID:birkir,项目名称:kvikmyndr-app,代码行数:32,代码来源:Movie.ts

示例4:

import { types } from 'mobx-state-tree';

export const Gender = types.enumeration('Gender', [
  'MALE',
  'FEMALE',
  'UNKNOWN',
]);
开发者ID:birkir,项目名称:kvikmyndr-app,代码行数:7,代码来源:Gender.ts

示例5:

import { types } from 'mobx-state-tree';
import { Cast } from './Cast';

const CreditType = types.enumeration('CreditType', [
  'CAST',
  'CREW',
]);

export const Credit = types.model('Credit', {
  id: types.identifier,
  cast: types.maybeNull(Cast),
  role: types.maybe(types.string),
  type: types.maybe(CreditType),
});

export type ICredit = typeof Credit.Type;
开发者ID:birkir,项目名称:kvikmyndr-app,代码行数:16,代码来源:Credit.ts

示例6:

export const Browsers = {
  inApp: 'In-App',
  default: Platform.select({ ios: 'Safari', android: 'Chrome' }),
};

export const Languages = {
  en: 'English',
  is: 'Íslenska',
};

export const Themes = {
  light: 'Light',
  dark: 'Dark',
};

export const SortBy = types.enumeration('SortBy', Object.keys(SortBys));
export const Theme = types.enumeration('Theme', Object.keys(Themes));
export const Language = types.enumeration('Language', Object.keys(Languages));
export const Browser = types.enumeration('Browser', Object.keys(Browsers));

export const Settings = types.model('Settings', {
  theme: types.optional(Theme, 'dark'),
  language: types.optional(Language, 'en'),
  promptOnExit: types.optional(types.boolean, true),
  posterAnimation: types.optional(types.boolean, true),
  hideSynopsis: types.optional(types.boolean, false),
  hideCast: types.optional(types.boolean, false),
  hideDaysOnScroll: types.optional(types.boolean, false),
  useReaderMode: types.optional(types.boolean, false),
  browser: types.optional(Browser, 'inApp'),
  weekSortBy: types.optional(SortBy, 'popularity'),
开发者ID:birkir,项目名称:kvikmyndr-app,代码行数:31,代码来源:Settings.ts


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