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


TypeScript List.delete方法代码示例

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


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

示例1: updateActivityInMention

    updateActivityInMention(kind: TimelineActivityKind, status: Tweet, from: TwitterUser): [List<Item>, number] {
        const status_id = status.id;
        const index = this.mention.findIndex(item => {
            if (item instanceof TimelineActivity) {
                return item.kind === kind && item.status.id === status_id;
            } else {
                return false;
            }
        });

        const next_focus_index =
            this.kind === 'mention' && (index === -1 || index < this.focus_index) ?
                this.nextFocusIndex(this.mention.size + 1) : this.focus_index;

        if (index === -1) {
            return [this.mention.unshift(new TimelineActivity(kind, status, [from])), next_focus_index];
        } else {
            const will_updated = this.mention.get(index);
            if (will_updated instanceof TimelineActivity) {
                const updated = will_updated.update(status, from);
                return [this.mention.delete(index).unshift(updated), next_focus_index];
            } else {
                log.error('Invalid activity for update:', will_updated);
                return [this.mention, next_focus_index];
            }
        }
    }
开发者ID:DevenLu,项目名称:YourFukurou,代码行数:27,代码来源:timeline.ts

示例2: function

export default function(state: List<TaskModel>, action: ITaskAction) {

  function indexOf(id: string): number {
    return state.findIndex((i: TaskModel) => i.id === id);
  }

  switch (action.type) {
    case LOAD_TASKS:
      state = action.taskList;
      return List<TaskModel>(state);
    case UPDATE_TASK:
      let index = state.findIndex((task) => task.id === action.task.id);
      return state.set(
        index,
        new TaskModel({
          id: action.task.id,
          title: action.task.title,
          details: action.task.details,
          dueDate: action.task.dueDate,
          completed: action.task.completed,
          completedDate: action.task.completedDate
        })
      );
    case COMPLETE_TASK:
      let completedTaskIndex = state.findIndex((task) => task.id === action.id);
      return state.delete(completedTaskIndex);
    case ADD_TASK:
      return state.push(action.task);
    default:
      return List<TaskModel>(state);
  }
}
开发者ID:wsquared,项目名称:angular2-task,代码行数:32,代码来源:taskReducer.ts

示例3: rowRemoved

function rowRemoved(rows: List<any>, { row }) {
  let index = indexForRow(rows, row.id);

  if (index > -1) {
    return rows.delete(index)
  } else {
    return rows;
  }
}
开发者ID:rosendi,项目名称:figure,代码行数:9,代码来源:syncronize_array.ts

示例4: rowMoved

function rowMoved(rows: List<any>, { row, prevRowId }) {
  const currIndex = indexForRow(rows, row.id);

  if (currIndex > -1) {
    const row = rows.get(currIndex);
    rows = rows.delete(currIndex);

    const newIndex = nextRowIndex(rows, prevRowId);
    rows = rows.splice(newIndex, 0, row).toList();

    return rows;
  }

  return rows;
}
开发者ID:rosendi,项目名称:figure,代码行数:15,代码来源:syncronize_array.ts

示例5: todos

function todos(state: List<Todo>, action) {
    if (!state) {
        return List([]);
    }
    switch(action.type) {
        case LOAD_TODOS:
            return List(action.todos);
        case ADD_TODO:
            return state.push(action.newTodo);
        case TOGGLE_TODO:
            return toggleTodo(state, action);
        case DELETE_TODO:
            let index = state.findIndex((todo) => todo.id === action.todo.id);
            return state.delete(index);
        default:
            return state;
    }
}
开发者ID:pedrogusman,项目名称:ionic-2-redux-starter,代码行数:18,代码来源:todoReducers.ts

示例6: todosReducer

function todosReducer(state: List<Todo> = List([]), action) {
  switch (action.type) {
    case LOAD_TODOS:
      return List(action.todos);
    case ADD_TODO:
      return state.push(action.newTodo);
    case TOGGLE_TODO:
      return toggleTodo(state, action);
    case TOGGLE_ALL_TODO:
      return toggleAllTodo(state, action.completed);
    case DELETE_TODO:
      let index = state.findIndex((todo) => todo.id === action.todo.id);
      return state.delete(index);
    case SET_CURRENT_FILTER:
      return state.map(todo => todo);
    case '@@redux-pouchdb-plus/SET_REDUCER':
      return state.map(todo => new Todo(todo.toJS()));
    default:
      return state;
  }
}
开发者ID:tedliang,项目名称:angular2-redux-starter,代码行数:21,代码来源:todo.ts

示例7: calculateTodos

export function calculateTodos(state: List<Todo>, action) {
    if (!state) {
        return List([]);
    }

    if (action instanceof  LoadTodosAction) {
        return List(action.todos);
    }
    else if (action instanceof AddTodoAction) {
        return state.push(action.newTodo);
    }
    else if (action instanceof ToggleTodoAction) {
        return toggleTodo(state, action);
    }
    else if (action instanceof DeleteTodoAction) {
        let index = state.findIndex((todo) => todo.id === action.todo.id);
        return state.delete(index);
    }
    else {
        return state;
    }
}
开发者ID:dmattsson,项目名称:angular2-rxjs-single-atom-example,代码行数:22,代码来源:reducers.ts

示例8: putInHome

    putInHome(status: Tweet): [List<Item>, number] {
        if (!status.isRetweet()) {
            return [this.home.unshift(status), this.nextFocusIndex(this.home.size + 1)];
        }

        const status_id = status.retweeted_status.id;
        const index = this.home.findIndex(item => {
            if (item instanceof Tweet) {
                return item.isRetweet() && item.retweeted_status.id === status_id;
            } else {
                return false;
            }
        });

        const next_focus_index =
            this.kind === 'home' && (index === -1 || index < this.focus_index) ?
                this.nextFocusIndex(this.home.size + 1) : this.focus_index;

        if (index === -1) {
            return [this.home.unshift(status), next_focus_index];
        }

        return [this.home.delete(index).unshift(status), next_focus_index];
    }
开发者ID:DevenLu,项目名称:YourFukurou,代码行数:24,代码来源:timeline.ts


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