Skip to content

Commit

Permalink
Merge pull request #8 from willowtreeapps/feature/reset
Browse files Browse the repository at this point in the history
Provides a mechanims to reset the container
  • Loading branch information
rafcabezas committed May 1, 2024
2 parents 1259603 + 2ca6e67 commit 9d29e0d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Sources/Grove/Grove.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ public final class Grove: @unchecked Sendable {
}
}

/// Resets the container
public func reset() {
dependencyItemsMapLock.lock()
dependencyItemsMap.removeAll()
dependencyItemsMapLock.unlock()
}

// MARK: Helpers

private func key<Dependency>(for type: Dependency.Type) -> ObjectIdentifier {
Expand Down
1 change: 1 addition & 0 deletions Sources/Grove/GroveRegistrar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public struct GroveRegistrar {
unitTestOverrides: ((Grove) -> Void)? = nil,
uiAutomationOverrides: ((Grove) -> Void)? = nil
) {
container.reset()
baseDependencies(container)

switch RunState(developmentModeEnvironmentVariable: developmentModeEnvironmentVariable) {
Expand Down

0 comments on commit 9d29e0d

Please sign in to comment.