This PR contains the work that implements the Dependency service, which is used as a dependency injection mechanism in the application. To give further details on what was done: - [x] created the `Dependency` library into the **Libraries** package; - [x] defined the `DependencyKey` protocol; - [x] implemented the `DependencyService` service; - [x] implemented the `Dependency` property wrapper. Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Reviewed-on: rock-n-code/deep-linking-assignment#6
23 lines
534 B
Swift
23 lines
534 B
Swift
//
|
|
// DependencyKey.swift
|
|
// Dependency
|
|
//
|
|
// Created by Javier Cicchelli on 11/04/2023.
|
|
// Copyright © 2023 Röck+Cöde. All rights reserved.
|
|
//
|
|
|
|
/// This protocol defines a key to use in the dependency service.
|
|
public protocol DependencyKey {
|
|
|
|
// MARK: Associated types
|
|
|
|
/// The associated type representing the type of the dependency key's value.
|
|
associatedtype Value
|
|
|
|
// MARK: Properties
|
|
|
|
/// The default value for the dependency key.
|
|
static var currentValue: Value { get set }
|
|
|
|
}
|