Skip to content

Commit

Permalink
Merge pull request #9 from WhoopInc/ncipollo/3/type-cleanup
Browse files Browse the repository at this point in the history
Fixes #3 Cleanup types within ServiceDictionary
  • Loading branch information
ncipollo authored Dec 14, 2023
2 parents 2224c22 + aa8f45e commit 4e75f9b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: "Test"
on: [push, pull_request]
on:
push:
branches: ["main", "release*"]
pull_request:

jobs:
test:
Expand Down
6 changes: 3 additions & 3 deletions Sources/WhoopDIKit/ServiceDictionary.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
public final class ServiceDictionary<Value> {
private var valuesByType: [AnyHashable: Value]
private var valuesByType: [ServiceKey: Value]

convenience public init() {
self.init(valuesByType: [:])
}

private init(valuesByType: [AnyHashable: Value]) {
private init(valuesByType: [ServiceKey: Value]) {
self.valuesByType = valuesByType
}

Expand All @@ -27,7 +27,7 @@ public final class ServiceDictionary<Value> {
}
}

public func allKeys() -> Set<AnyHashable> {
public func allKeys() -> Set<ServiceKey> {
Set(valuesByType.keys)
}

Expand Down
3 changes: 1 addition & 2 deletions Sources/WhoopDIKit/WhoopDI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ public final class WhoopDI: DependencyRegister {

/// Used internally via the `WhoopDIValidator` to verify all definitions in the object graph have definitions for their sub-dependencies (i.e this verifies the object graph is complete).
internal static func validate(paramsDict: ServiceDictionary<Any>, onFailure: (Error) -> Void) {
serviceDict.allKeys().forEach { key in
let serviceKey = key as! ServiceKey
serviceDict.allKeys().forEach { serviceKey in
let definition = getDefinition(serviceKey)
do {
let _ = try definition?.get(params: paramsDict[serviceKey])
Expand Down

0 comments on commit 4e75f9b

Please sign in to comment.