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


TypeScript List.first方法代码示例

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


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

示例1: addSeparator

 addSeparator(sep: Separator) {
     const next_home =
         this.home.first() instanceof Separator ?
             this.home :
             this.home.unshift(sep);
     const next_mention =
         this.mention.first() instanceof Separator ?
             this.mention :
             this.mention.unshift(sep);
     const next_focus_index =
         (next_home !== this.home && this.kind === 'home') ||
         (next_mention !== this.mention && this.kind === 'mention') ?
             this.nextFocusIndex(next_home.size) : this.focus_index;
     return new TimelineState(
         this.kind,
         next_home,
         next_mention,
         this.user,
         this.notified,
         this.rejected_ids,
         this.no_retweet_ids,
         next_focus_index
     );
 }
开发者ID:DevenLu,项目名称:YourFukurou,代码行数:24,代码来源:timeline.ts

示例2: selectAutocompleteItem

export const selectNextAutocompleteItem = (options: List<AutocompleteItem>, current: AutocompleteItem) => {
  const index: number = options.findIndex((option) => option === current);
  const item: AutocompleteItem = index === options.size - 1 ? options.first() : options.get(index + 1);
  return selectAutocompleteItem(item);
};
开发者ID:threehams,项目名称:reverie-client,代码行数:5,代码来源:commandActions.ts

示例3: defaultLinkItem

 public defaultLinkItem(): LinkItem {
   return this.linkItems.first();
 }
开发者ID:coconutpalm,项目名称:pivot,代码行数:3,代码来源:link-view-config.ts

示例4: reducer


//.........这里部分代码省略.........
      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'])

      const stacksWithEmbedded = embedAnnotations(timelineDuration, annotationStacks, annotationStackIndex, List([annotation]), List([prevAnnotation]))

      const annotationId = annotation.get('id', null)!
      const singleSel: Record<AnnotationSelection> = state.getIn(['selection', 'annotation', 'selected'])
      const inSelection = singleSel !== null && singleSel.getIn(['annotation', 'id']) === annotationId ? singleSel : null

      let updatedState = state
      if(inSelection) {
        const updatedSingleSel = inSelection.set('annotation', annotation)
        updatedState = state.setIn(['selection', 'annotation', 'selected'], updatedSingleSel)
      }
      return updatedState.setIn(path, stacksWithEmbedded)
    }
    case project.PROJECT_DELETE_SELECTED_ANNOTATIONS: {
      const all = getAllSelections(state)
      // const selectedAnnotations = all.map(annotationSelection => {
      //   return annotationSelection.get('annotation', null)!
      // })

      // const selectedAnnotationsList = selectedAnnotations.toList()

      if(!all.isEmpty()) {
        const firstSelAnnotation = all.first() as Record<AnnotationSelection>
        const selectedTrack = firstSelAnnotation.get('track', null)!
        const tracks: List<Record<Track>> = state.getIn(['meta', 'timeline', 'tracks'])
        const trackIndex = tracks.findIndex(t => t.get('id', null) === selectedTrack.get('id', null))!
        const annotationStacks: List<List<Record<Annotation>>> = tracks.get(trackIndex)!.get('annotationStacks', null)

        const timelineDuration = state.getIn(['meta', 'timeline', 'duration'])

        /**
         * TODO:
         * This is a quick fix solution.
         * Removing the selected annotations should not be implemented via `forEach`.
         * Instead one single call to `embedAnnotations(...)` with the list of
         * selected annotation to be removed.
         * Currently `embedAnnotations` only supports removing a single annotation at a time
         * due to historical reasons.
         * `embedAnnotations` needs to be adapted to support removing a list of annotations in a
         * single call.
         */
        let updatedStacks = annotationStacks
        all.forEach(removeAnnotationSel => {
          const annotation = removeAnnotationSel.get('annotation', null)!
          const annotationStackIndex = removeAnnotationSel.get('annotationStackIndex', null)!

          updatedStacks = embedAnnotations(timelineDuration, updatedStacks, annotationStackIndex, List([]), List([annotation]))
        })

        // remove stacks without annotations
        const cleanedStacks = updatedStacks.size > 1 ? updatedStacks.filter(stack => stack.size > 0): updatedStacks

        return state.setIn(['meta', 'timeline', 'tracks', trackIndex, 'annotationStacks'], cleanedStacks)
          .setIn(['selection', 'annotation', 'range'], Set())
          .setIn(['selection', 'annotation', 'pick'], Set())
开发者ID:StudioProcess,项目名称:rvp,代码行数:67,代码来源:project.ts


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