本文整理汇总了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];
}
}
}
示例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);
}
}
示例3: rowRemoved
function rowRemoved(rows: List<any>, { row }) {
let index = indexForRow(rows, row.id);
if (index > -1) {
return rows.delete(index)
} else {
return rows;
}
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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];
}