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


TypeScript types.maybeNull方法代码示例

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


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

示例1:

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

export const Cast = types.model('Cast', {
  id: types.identifier,
  name: types.maybeNull(types.string),
  pictureUrl: types.maybeNull(types.string),
});
开发者ID:birkir,项目名称:kvikmyndr-app,代码行数:7,代码来源:Cast.ts

示例2:

  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),
  title: types.maybeNull(types.string),
  year: types.maybeNull(types.number),
  summary: types.maybeNull(types.string),
  runtime: types.maybeNull(types.number),
  backdropUrl: types.maybeNull(types.string),
  posterUrl: types.maybeNull(types.string),
开发者ID:birkir,项目名称:kvikmyndr-app,代码行数:31,代码来源:Movie.ts

示例3: updateDescription

import { types, flow } from 'mobx-state-tree';
import CodePush from 'react-native-code-push';
import VersionNumber from 'react-native-version-number';
import { UpdateMetadata } from './models/UpdateMetadata';

export const Update = types
  .model('Update', {
    updateMetadata: types.maybeNull(UpdateMetadata),
    version: VersionNumber.appVersion,
    build: VersionNumber.buildVersion,
  })
  .views(self => ({
    get updateDescription() {
      const { description = null } = self.updateMetadata || {};
      return description;
    },
    get updateVersion() {
      const { label = null } = self.updateMetadata || {};
      return label;
    },
    get appVersion() {
      return `${self.version || 'unknown'}${self.build ? ` (build ${self.build})` : ''}`;
    },
  }))
  .actions(self => ({
    update() {
      return flow(function* () {
        self.updateMetadata = yield CodePush.getUpdateMetadata();
      })();
    },
  }))
开发者ID:birkir,项目名称:kvikmyndr-app,代码行数:31,代码来源:update.ts

示例4:

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


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