(title: string)
| 40 | } |
| 41 | |
| 42 | export async function addTodoOnServer(title: string): Promise<Todo> { |
| 43 | await delay(70) |
| 44 | if (failNextMutation) { |
| 45 | failNextMutation = false |
| 46 | throw new Error('Forced mutation failure (test)') |
| 47 | } |
| 48 | |
| 49 | const nextTodo: Todo = { |
| 50 | id: nextTodoId, |
| 51 | title, |
| 52 | } |
| 53 | |
| 54 | nextTodoId += 1 |
| 55 | todos = [...todos, nextTodo] |
| 56 | |
| 57 | return { ...nextTodo } |
| 58 | } |
| 59 | |
| 60 | export function resetTodoApi(): void { |
| 61 | todos = [ |