Skip to content

Commit

Permalink
Moved @mainactor to init
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Radu committed Apr 29, 2022
1 parent 30fffb5 commit 38f1153
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 3 additions & 8 deletions Sources/Toledo/Dependency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ public protocol DependencyKey {

@MainActor
public struct SharedContainer {
static var all: [AnyHashable: Any] = [:]

private var _values: [ObjectIdentifier: Any] = [:]

public init() {}
Expand Down Expand Up @@ -120,17 +118,14 @@ public class _DependencyProvider<V> where V: Dependency {
}
}

@MainActor
public protocol AsyncThrowingDependency {
init(with: SharedContainer) async throws
@MainActor init(with: SharedContainer) async throws
}

@MainActor
public protocol ThrowingDependency {
init(with: SharedContainer) throws
@MainActor init(with: SharedContainer) throws
}

@MainActor
public protocol Dependency {
init(with: SharedContainer)
@MainActor init(with: SharedContainer)
}
2 changes: 1 addition & 1 deletion Tests/ToledoTests/Fixtures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public struct C: AsyncThrowingDependency {

public struct LongLastingInit: AsyncThrowingDependency {
let id: UUID
public init(with _: SharedContainer) async throws {
public init(with container: SharedContainer) async throws {
id = UUID()
try await Task.sleep(nanoseconds: 1 * NSEC_PER_SEC)
}
Expand Down

0 comments on commit 38f1153

Please sign in to comment.