Skip to content

Commit

Permalink
Remove Waiter for simple solution
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLeif committed Feb 23, 2024
1 parent ebbbbd5 commit 30ebe7e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 30 deletions.
8 changes: 2 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ let package = Package(
)
],
dependencies: [
.package(url: "https://github.com/0xLeif/Cache", from: "2.0.0"),
.package(url: "https://github.com/0xLeif/Waiter", from: "1.0.0")
.package(url: "https://github.com/0xLeif/Cache", from: "2.0.0")
],
targets: [
.target(
Expand All @@ -30,10 +29,7 @@ let package = Package(
),
.testTarget(
name: "AppStateTests",
dependencies: [
"AppState",
"Waiter"
]
dependencies: ["AppState"]
)
]
)
20 changes: 5 additions & 15 deletions Sources/AppState/Application/Application+public.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,10 @@ public extension Application {
column: column
)

let setValue = {
shared.cache.set(
value: dependency,
forKey: dependency.scope.key
)
}

#if (!os(Linux) && !os(Windows))
Task {
setValue()
}
#else
setValue()
#endif
shared.cache.set(
value: dependency,
forKey: dependency.scope.key
)
}
}

Expand Down Expand Up @@ -209,7 +199,7 @@ public extension Application {
)

var promotions = Application.state(\.dependencyPromotions)
promotions.value[String(describing: keyPath)] = promotionOverride
promotions.value.append(promotionOverride)

return Application.self
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extension Application {
var dependencyPromotions: State<[String: DependencyOverride]> {
state(initial: [:])
var dependencyPromotions: State<[DependencyOverride]> {
state(initial: [])
}

/// `Dependency` struct encapsulates dependencies used throughout the app.
Expand Down
7 changes: 0 additions & 7 deletions Tests/AppStateTests/AppDependencyTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Waiter
import XCTest
@testable import AppState

Expand Down Expand Up @@ -76,12 +75,6 @@ final class AppDependencyTests: XCTestCase {

networkingOverride.cancel()

try await Waiter.wait(
on: Application.shared,
for: \.networking,
expecting: { $0.value is NetworkService }
)

let networkingService = Application.dependency(\.networking)

XCTAssertNotNil(networkingService as? NetworkService)
Expand Down

0 comments on commit 30ebe7e

Please sign in to comment.