Skip to content

Commit

Permalink
Now on Swift 6 we use the MainActor for setting (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLeif authored Oct 12, 2024
1 parent fd36a42 commit 13b3481
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions Sources/AppState/Application/Types/State/Application+State.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,14 @@ extension Application {
)
else {
defer {
let setValue = {
shared.cache.set(
value: Application.State(
type: .state,
initial: _value,
scope: scope
),
forKey: scope.key
)
}

#if (!os(Linux) && !os(Windows))
if NSClassFromString("XCTest") == nil {
Task {
await MainActor.run {
setValue()
}
}
} else {
setValue()
}
#else
setValue()
#endif
shared.cache.set(
value: Application.State(
type: .state,
initial: _value,
scope: scope
),
forKey: scope.key
)
}
return _value
}
Expand Down

0 comments on commit 13b3481

Please sign in to comment.