This PR contains the work done to decouple the direct use of the `ModelContext` from `SwiftData` from the view model that uses it. In addition, the project transitioned to use Swift 6 and strict concurrency which brought some issues with the unit tests, so they were amended as well. Reviewed-on: rock-n-code/todos-app#8 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
29 lines
1.1 KiB
Swift
29 lines
1.1 KiB
Swift
import SwiftData
|
|
|
|
/// A protocol defining the interface for a todo repository.
|
|
///
|
|
/// This protocol abstracts the underlying data persistence mechanism for todo tasks,
|
|
/// allowing for dependency injection and easier testing. Implementations handle the
|
|
/// storage and retrieval of Todo objects.
|
|
protocol TodoRepository {
|
|
|
|
/// Deletes a todo task from the repository.
|
|
///
|
|
/// This method removes the specified todo from persistent storage. The deletion
|
|
/// is typically performed immediately, though the actual persistence may be deferred
|
|
/// until a save operation occurs depending on the implementation.
|
|
///
|
|
/// - Parameter todo: The todo task to delete from the repository.
|
|
func delete(_ todo: Todo)
|
|
|
|
/// Inserts a new todo task into the repository.
|
|
///
|
|
/// This method adds a new todo to persistent storage. The todo is typically
|
|
/// tracked immediately, though the actual persistence may be deferred until a
|
|
/// save operation occurs depending on the implementation.
|
|
///
|
|
/// - Parameter todo: The todo task to insert into the repository.
|
|
func insert(_ todo: Todo)
|
|
|
|
}
|