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


TypeScript List.concat方法代码示例

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


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

示例1: todosReducer

function todosReducer(state:List<ITask>, action:IAction):List<ITask> {
        console.log(`todosReducer: Action(${JSON.stringify(action)})`);
        switch(action.type) {
                case Keys.AddTodo:
                    var todos: List<ITask> = List<ITask>(state.concat([action.payload]));
                    console.log(`todosReducer: todos(${JSON.stringify(todos)})`);
                    return todos;
                case Keys.CompleteTodo:
                        return List<ITask>(state.map((task:ITask) => {
                                if (task.Id === action.payload.Id) {
                                        return new Task(
                                                task.Id,
                                                task.Title,
                                                task.Description,
                                                action.payload.Complete
                                        );
                                } else {
                                        return task;
                                }
                        }));
                case Keys.RemoveTodo:
                        return List<ITask>(state.filter((task:ITask) => {
                                return task.Id !== action.payload.Id;
                        }))
        }                                 
        return state || initialState.todos;
}
开发者ID:darcy-buttrose,项目名称:react-redux-jest-webapi,代码行数:27,代码来源:Reducer.ts

示例2: getState

 getState(path: Array<string> | List<string> | string = List([])): any {
   let newPath: List<string>;
   if (typeof path === 'string') {
     newPath = List([path]);
   } else {
     newPath = fromJS(path);
   }
   return this.rootStore.state.getIn(this.path.concat(newPath));
 }
开发者ID:mremolt,项目名称:icndb-ng2-webpack,代码行数:9,代码来源:Store.ts

示例3: process

  /**
   * Function that intented to be used by the table plugin manager to
   * perform the sorting process. It supports sorting with mutiple sorter,
   * which will be performed in ASC order.
   *
   * NOTE: the sorting process will short circuit on any non-zero sorter
   *       result.
   */
  process(tableData: TableData, columns: List<ColumnDef>) {
    const columnSorters: Iterable<number, TableSorter> = columns
      .filterNot(s => _.isUndefined(s.sortable))
      .map(columnDef => {
        const sorter     = columnDef.sortable
        const selector   = columnDef.field
        const type       = columnDef.type
        const order      = sorter.order
        const comparator = sorter.comparator || this.getComparator(type)

        return { order, selector, comparator }
      })

    const sorters = this.sorters.concat(columnSorters)
      .filter(s => this.getSortOrder(s.order) !== NONE)

    if (sorters.size > 1 && !this.multiSortable) {
      if (process.env.NODE_ENV === 'development') {
        throw new Error(`[RCBOX] Found multiple sorter enabled while this` +
          `feature is disabled. To enable this feature, set 'multiSortable' ` +
          `property to 'true' on TableSortPlugin. Those unexpected sorters ` +
          `are: ${sorters.toJS()}`)
      }
      // NOTE: Returns unsorted table data as fallback to avoid uncertain
      //       data will be used in production environment.
      return tableData
    }

    const sorted = tableData.sort((row1, row2) => {
      const reducer = (result: number, sorter: TableSorter) => {
        const { selector, comparator } = sorter
        const order = this.getSortOrder(sorter.order)
        const factor = order === DESC ? -1 : 1

        return result !== 0
          ? result
          : comparator(selector(row1), selector(row2)) * factor
      }
      return sorters.reduce(reducer, 0)
    })

    return sorted
  }
开发者ID:zhenwenc,项目名称:rc-box,代码行数:51,代码来源:SortingPluginImpl.ts

示例4: todosReducer

function todosReducer(state:List<ITask>, action:IAction):List<ITask> {
        switch(action.key) {
                case Keys.AddTodo:
                        return List<ITask>(state.concat([action.payload]))
                case Keys.CompleteTodo:
                        return List<ITask>(state.map((task:ITask) => {
                                if (task.Id === action.payload.Id) {
                                        return new Task(
                                                task.Id,
                                                task.Title,
                                                task.Description,
                                                action.payload.Complete
                                        );
                                } else {
                                        return task;
                                }
                        }));
                case Keys.RemoveTodo:
                        return List<ITask>(state.filter((task:ITask) => {
                                return task.Id !== action.payload.Id;
                        }))
        }                                 
        return state;
}
开发者ID:darcy-buttrose,项目名称:react-redux-bootstrap-todo,代码行数:24,代码来源:Reducer.ts


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