[Improvement] Small, tiny things #14

Merged
javier merged 4 commits from improvement/various into main 2023-04-13 13:34:07 +00:00
4 changed files with 30 additions and 5 deletions
Showing only changes of commit 2b38e03094 - Show all commits

View File

@ -0,0 +1,19 @@
//
// Service.swift
// Remote
//
// Created by Javier Cicchelli on 13/04/2023.
// Copyright © 2023 Röck+Cöde. All rights reserved.
//
import Foundation
public protocol Service {
// MARK: Functions
/// Retrieve a set of locations.
/// - Returns: The set of locations represented as a `Location` instances.
func getLocations() async throws -> [Location]
}

View File

@ -21,6 +21,12 @@ public struct RemoteService {
self.client = RemoteClient(configuration: configuration)
}
}
// MARK: - Service
extension RemoteService: Service {
// MARK: Functions
public func getLocations() async throws -> [Location] {
@ -29,7 +35,7 @@ public struct RemoteService {
for: Locations.self
).locations
}
}
// MARK: - Models

View File

@ -18,7 +18,7 @@ extension DependencyService {
set { Self[PersistenceKey.self] = newValue }
}
var remote: RemoteService {
var remote: Remote.Service {
get { Self[RemoteKey.self] }
set { Self[RemoteKey.self] = newValue }
}
@ -31,5 +31,5 @@ struct PersistenceKey: DependencyKey {
}
struct RemoteKey: DependencyKey {
static var currentValue: RemoteService = .init()
static var currentValue: Remote.Service = RemoteService()
}

View File

@ -16,13 +16,13 @@ struct LoadRemoteLocationsUseCase {
// MARK: Properties
private let persistence: PersistenceService
private let remoteService: RemoteService
private let remoteService: Remote.Service
// MARK: Initialisers
init(
persistence: PersistenceService,
remoteService: RemoteService
remoteService: Remote.Service
) {
self.persistence = persistence
self.remoteService = remoteService