Are you ready to enhance the functionality of your TodoList application? In this unit, we shift our focus towards dynamic task management by adding and removing tasks. You will build upon your foundational knowledge of Elixir structs and deepen your understanding of managing tasks efficiently.
In this unit, we'll extend our TodoList application by implementing the following key functionalities:
-
Task Addition: We'll create a function to add new tasks to our list, which assigns unique IDs to each task for easy identification.
-
Task Removal: We'll develop a function that allows tasks to be removed from the list using their IDs.
These functionalities will significantly enhance your ability to manage tasks within your application. Here's a refresher on some important Elixir functions that we'll utilize in our implementation:
- Enum.reject/2: Used to filter out specific elements from a list based on a given condition.
Elixir
1Enum.reject(tasks, fn task -> task.id == id end)
- Structs: We'll continue to utilize Elixir's structs to define the structure and default values of each task.
Elixir
1%TodoList{id: length(tasks) + 1, task: task}
By the end of this unit, you'll have an interactive and refined TodoList application setup ready for the next development phases.