Deprecate IoC namespace
This commit is contained in:
parent
e28cf84d3c
commit
0b99113342
|
@ -11,7 +11,8 @@ This version adjusts the library for Xcode 14 and deprecates some things.
|
|||
|
||||
### 🗑 Deprecations
|
||||
|
||||
* The `StoreKit` namespace has been deprecated and moved to a new library: https://github.com/danielsaidi/StoreKitPlus
|
||||
* The `IoC` namespace has been deprecated and will be removed in the next major version.
|
||||
* The `StoreKit` namespace has been deprecated and moved to https://github.com/danielsaidi/StoreKitPlus
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -120,13 +120,6 @@ This namespace contains iCloud-specific extensions as well as utils:
|
|||
- ``iCloudDocumentSync``
|
||||
- ``StandardiCloudDocumentSync``
|
||||
|
||||
### IoC
|
||||
|
||||
This namespace contains disabled `Dip` and `Swinject` containers.
|
||||
|
||||
- ``IoC``
|
||||
- ``IoCContainer``
|
||||
|
||||
### Keychain
|
||||
|
||||
- ``KeychainReader``
|
||||
|
|
|
@ -20,6 +20,7 @@ import Foundation
|
|||
If you don't want to use an IoC container, you can just use
|
||||
the `IoC` class as a container for static properties.
|
||||
*/
|
||||
@available(*, deprecated, message: "This type has been deprecated and will be removed in the next major version.")
|
||||
public final class IoC {
|
||||
|
||||
public private(set) static var container: IoCContainer!
|
|
@ -14,6 +14,7 @@ import Foundation
|
|||
inversion of control, by dynamically resolving types, given
|
||||
any required arguments.
|
||||
*/
|
||||
@available(*, deprecated, message: "This type has been deprecated and will be removed in the next major version.")
|
||||
public protocol IoCContainer {
|
||||
|
||||
func resolve<T>() -> T
|
|
@ -1,65 +0,0 @@
|
|||
//
|
||||
// IoCTests.swift
|
||||
// SwiftKitTests
|
||||
//
|
||||
// Created by Daniel Saidi on 2016-11-17.
|
||||
// Copyright © 2020 Daniel Saidi. All rights reserved.
|
||||
//
|
||||
|
||||
import Quick
|
||||
import Nimble
|
||||
import SwiftKit
|
||||
|
||||
class IoCTests: QuickSpec {
|
||||
|
||||
override func spec() {
|
||||
|
||||
describe("registering container") {
|
||||
|
||||
it("registers shared container") {
|
||||
IoC.register(TestClass())
|
||||
}
|
||||
}
|
||||
|
||||
describe("resolving dependencies") {
|
||||
|
||||
it("uses shared container") {
|
||||
let message = IoC.resolve() as String
|
||||
expect(message).to(equal("foo"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class TestClass: IoCContainer {
|
||||
|
||||
func resolve<T>() -> T {
|
||||
guard let result = "foo" as? T else { fatalError() }
|
||||
return result
|
||||
}
|
||||
|
||||
func resolve<T, A>(arguments arg1: A) -> T {
|
||||
guard let result = "foo" as? T else { fatalError() }
|
||||
return result
|
||||
}
|
||||
|
||||
func resolve<T, A, B>(arguments arg1: A, _ arg2: B) -> T {
|
||||
guard let result = "foo" as? T else { fatalError() }
|
||||
return result
|
||||
}
|
||||
|
||||
func resolve<T, A, B, C>(arguments arg1: A, _ arg2: B, _ arg3: C) -> T {
|
||||
guard let result = "foo" as? T else { fatalError() }
|
||||
return result
|
||||
}
|
||||
|
||||
func resolve<T, A, B, C, D>(arguments arg1: A, _ arg2: B, _ arg3: C, _ arg4: D) -> T {
|
||||
guard let result = "foo" as? T else { fatalError() }
|
||||
return result
|
||||
}
|
||||
|
||||
func resolve<T, A, B, C, D, E>(arguments arg1: A, _ arg2: B, _ arg3: C, _ arg4: D, _ arg5: E) -> T {
|
||||
guard let result = "foo" as? T else { fatalError() }
|
||||
return result
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue