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


TypeScript Record.get方法代码示例

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


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

示例1: nextTrackId

function nextTrackId(timeline: Record<Timeline>): number {
  let maxId = -1
  const tracks = timeline.get('tracks', [])
  tracks.forEach(track => {
    const curId = track.get('id', -1) as number
    if(curId > maxId) {
      maxId = curId
    }
  })

  return maxId+1
}
开发者ID:StudioProcess,项目名称:rvp,代码行数:12,代码来源:project.ts

示例2: flattenAnnotations

function flattenAnnotations(timeline: Record<Timeline>|null) {
  if(timeline !== null) {
    return timeline.get('tracks', null).flatMap((track, trackIndex) => {
      const color = track.get('color', null)
      return track.get('annotationStacks', null).flatMap((annotations, annotationStackIndex) => {
        return annotations.map((annotation, annotationIndex) => {
          return new AnnotationColorMapRecordFactory({
            track, trackIndex, color, annotation, annotationIndex, annotationStackIndex
          })
        })
      })
    })
  } else {
    return List([])
  }
}
开发者ID:StudioProcess,项目名称:rvp,代码行数:16,代码来源:index.ts

示例3: nextAnnotationId

function nextAnnotationId(timeline: Record<Timeline>): number {
  let maxId = -1
  const tracks = timeline.get('tracks', [])
  tracks.forEach(track => {
    const annotationStacks = track.get('annotationStacks', null)
    annotationStacks.forEach(annotations => {
      annotations.forEach(annotation => {
        const curId = annotation.get('id', -1) as number
        if(curId > maxId) {
          maxId = curId
        }
      })
    })
  })

  return maxId+1
}
开发者ID:StudioProcess,项目名称:rvp,代码行数:17,代码来源:project.ts

示例4: reducer

export function reducer(state: State = initialState, action: project.Actions): State {
  switch(action.type) {
    case project.PROJECT_LOAD_SUCCESS: {
      /* Handle new project:
       * For `new project` there is no defined video, therefore
       * the video data from the previous state is used.
       */
      const prevDuration = state.getIn(['meta', 'timeline', 'duration'])
      const prevVideoMeta = state.getIn(['meta', 'video'])
      const prevVideoBlob = state.get('videoBlob', null)

      const {meta: {id, timeline, video:videoMeta}, video} = action.payload

      if(videoMeta === null) {
        timeline.duration = prevDuration
      }

      if(videoMeta && videoMeta.type === VIDEO_TYPE_URL) {
        videoMeta.url = new URL(videoMeta.url)
      }
      // Create immutable representation
      return new ProjectRecordFactory({
        videoBlob: video === null ? prevVideoBlob: video,
        player: state.get('player', new ProjectPlayerStateRecordFactory()),
        meta: ProjectMetaRecordFactory({
          id,
          video: videoMeta === null ? prevVideoMeta : (videoMeta.type === VIDEO_TYPE_BLOB ? BlobVideoRecordFactory(videoMeta) : UrlVideoRecordFactory(videoMeta)),
          timeline: TimelineRecordFactory({
            ...timeline,
            tracks: List(timeline.tracks.map((track: any) => {
              const {title: trackTitle} = track.fields
              return new TrackRecordFactory({
                ...track,
                fields: TrackFieldsRecordFactory({title: trackTitle}),
                annotationStacks: List(track.annotationStacks.map((annotations: any) => {
                  return List(annotations.map((annotation: any) => {
                    const {description} = annotation.fields
                    return new AnnotationRecordFactory({
                      ...annotation,
                      fields: new AnnotationFieldsRecordFactory({description}),
                    })
                  }))
                }))
              })
            }))
          })
        })
      })
    }
    case project.PROJECT_IMPORT_VIDEO_SUCCESS: {
      const payload = action.payload
      switch(payload.type) {
        case VIDEO_TYPE_BLOB: {
          const blobVideo = payload.data as File|Blob
          return state
            .set('videoBlob', blobVideo)
            .setIn(['meta', 'video'], BlobVideoRecordFactory({type: VIDEO_TYPE_BLOB}))
        }
        case VIDEO_TYPE_URL: {
          const videoMeta = {
            type: VIDEO_TYPE_URL,
            source: payload.source as VideoUrlSource,
            url: payload.data as URL
          }
          return state
            .set('videoBlob', null)
            .setIn(['meta', 'video'], UrlVideoRecordFactory(videoMeta))
        }
      }
      return state
    }
    case project.PROJECT_SET_TIMELINE_DURATION: {
      return state.setIn(['meta', 'timeline', 'duration'], action.payload.duration)
    }
    case project.PROJECT_ADD_ANNOTATION: {
      const {trackIndex, annotationStackIndex, annotation, source} = action.payload

      let placedTrackIndex = trackIndex
      let placedAnnotation = annotation
      if(source === 'toolbar') {
        const tracks = state.getIn(['meta', 'timeline', 'tracks']) as List<Record<Track>>
        placedTrackIndex = tracks.findIndex(track => track.get('isActive', false))
        placedAnnotation = annotation.set('utc_timestamp', state.getIn(['player', 'currentTime']))
      }

      const annotationStacks = state.getIn(['meta', 'timeline', 'tracks', placedTrackIndex, 'annotationStacks'])
      const newId = nextAnnotationId(state.getIn(['meta', 'timeline']))
      const newAnnotation = placedAnnotation.set('id', newId)
      const timelineDuration = state.getIn(['meta', 'timeline', 'duration'])

      const stacksWithEmbedded = embedAnnotations(timelineDuration, annotationStacks, annotationStackIndex, List([newAnnotation]), List([]))
      return state.setIn(['meta', 'timeline', 'tracks', placedTrackIndex, 'annotationStacks'], stacksWithEmbedded)
    }
    case project.PROJECT_UPDATE_ANNOTATION: {
      const {trackIndex, annotationIndex, annotationStackIndex, annotation} = action.payload

      const path = ['meta', 'timeline', 'tracks', trackIndex, 'annotationStacks']
      const annotationStacks: List<List<Record<Annotation>>> = state.getIn(path)
      const prevAnnotation: Record<Annotation> = annotationStacks.getIn([annotationStackIndex, annotationIndex])
      const timelineDuration = state.getIn(['meta', 'timeline', 'duration'])
//.........这里部分代码省略.........
开发者ID:StudioProcess,项目名称:rvp,代码行数:101,代码来源:project.ts

示例5:

 const sortFunc = (a1: Record<Annotation>, a2: Record<Annotation>) => {
   return a1.get('utc_timestamp', null)! - a2.get('utc_timestamp', null)!
 }
开发者ID:StudioProcess,项目名称:rvp,代码行数:3,代码来源:project.ts

示例6:

const recordHasCollisionWithCursor = (timelineDuration: number, annotation: Record<Annotation>, currentTime: number) => {
  const left = annotation.get('utc_timestamp', null)
  const right = left+Math.max(timelineDuration/100*_HANDLEBAR_MIN_WIDTH_, annotation.get('duration', null))
  return left <= currentTime && right >= currentTime
}
开发者ID:StudioProcess,项目名称:rvp,代码行数:5,代码来源:annotationStack.ts

示例7: binarySearch

const mapIndicesFunc = (stack: List<Record<Annotation>>) => (annotation: Record<Annotation>) => {
  return binarySearch(stack, stack.size, (list, i) => {
    return list.getIn([i, 'utc_timestamp'])
  }, annotation.get('utc_timestamp', null))
}
开发者ID:StudioProcess,项目名称:rvp,代码行数:5,代码来源:annotationStack.ts


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