const remove = (todoCollection: TodoCollection, id: string): TodoCollection => { return todoCollection.withMutations(state => { let i = ReverseLookup.get(todoCollection.idTable, id).first(); let creatorID = todoCollection.todos.get(i).creatorID; return state .update("todos", todos => todos.remove(i)) .update("idTable", idTable => ReverseLookup.remove(idTable, id)) .update("creatorTable", creatorTable => ReverseLookup.remove(creatorTable, creatorID, i)); }); }
const remove = (todoListCollection: TodoListCollection, id: string): TodoListCollection => { const set = ReverseLookup.get(todoListCollection.indexTable, id); if (set) { return todoListCollection.withMutations((state) => { const i = set.first(); state .update("todoList", todoList => todoList.remove(i)) .update("indexTable", indexTable => ReverseLookup.remove(indexTable, id)); }); } return todoListCollection; }