Todo repository protocol #8

Merged
javier merged 11 commits from app/repository-protocol into main 2026-02-11 18:22:26 +00:00
Showing only changes of commit 85bd3f6a38 - Show all commits
@@ -57,14 +57,14 @@ extension NewTaskView {
// MARK: Functions // MARK: Functions
/// Saves a new todo task to the SwiftData model context. /// Saves a new todo task to the repository.
/// ///
/// This function creates a new `Todo` instance with the current property values and inserts it into the provided model context. /// This function creates a new `Todo` instance with the current property values and inserts it into the provided repository.
/// The title and note are trimmed of leading and trailing whitespace before saving. /// The title and note are trimmed of leading and trailing whitespace before saving.
/// The `note` property value is only included if it's not empty after trimming. /// The `note` property value is only included if it's not empty after trimming.
/// ///
/// - Parameter modelContext: The SwiftData model context to insert a new todo task. /// - Parameter repository: The repository to insert a new todo task.
func save(to modelContext: ModelContext) { func save(to repository: Repository) {
let trimmedTitle = title.trimmingCharacters(in: .whitespacesAndNewlines) let trimmedTitle = title.trimmingCharacters(in: .whitespacesAndNewlines)
let trimmedNote = note.trimmingCharacters(in: .whitespacesAndNewlines) let trimmedNote = note.trimmingCharacters(in: .whitespacesAndNewlines)
@@ -74,7 +74,7 @@ extension NewTaskView {
due: due due: due
) )
modelContext.insert(todo) repository.insert(todo)
} }
} }