Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use AnyHashableSendable from Concurrency Extras #3428

Merged
merged 5 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-concurrency-extras",
"state" : {
"revision" : "bb5059bde9022d69ac516803f4f227d8ac967f71",
"version" : "1.1.0"
"revision" : "6054df64b55186f08b6d0fd87152081b8ad8d613",
"version" : "1.2.0"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "9b77567b796b05ea9be9bbcac20aca003b91f34244a7fd2740f2b5306c013c45",
"originHash" : "876e72a5524942f6ac9fd0ebc53b055352a228c6f751c04f66249c1eeefd2cbc",
"pins" : [
{
"identity" : "combine-schedulers",
Expand Down Expand Up @@ -42,8 +42,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-concurrency-extras",
"state" : {
"revision" : "bb5059bde9022d69ac516803f4f227d8ac967f71",
"version" : "1.1.0"
"revision" : "6054df64b55186f08b6d0fd87152081b8ad8d613",
"version" : "1.2.0"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,17 @@ struct LongLivingEffects {
}

extension DependencyValues {
var screenshots: @Sendable () async -> AsyncStream<Void> {
var screenshots: @Sendable () async -> any AsyncSequence<Void, Never> {
get { self[ScreenshotsKey.self] }
set { self[ScreenshotsKey.self] = newValue }
}
}

private enum ScreenshotsKey: DependencyKey {
static let liveValue: @Sendable () async -> AsyncStream<Void> = {
AsyncStream(
NotificationCenter.default
.notifications(named: UIApplication.userDidTakeScreenshotNotification)
.map { _ in }
)
static let liveValue: @Sendable () async -> any AsyncSequence<Void, Never> = {
NotificationCenter.default
.notifications(named: UIApplication.userDidTakeScreenshotNotification)
.map { _ in }
}
}

Expand Down
7 changes: 0 additions & 7 deletions Examples/CaseStudies/SwiftUICaseStudies/FactClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,3 @@ extension FactClient: DependencyKey {
/// to prove do not need the dependency.
static let testValue = Self()
}

struct AnyHashableSendable: Hashable, @unchecked Sendable {
let base: AnyHashable
init<Base: Hashable & Sendable>(_ base: Base) {
self.base = base
}
}
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let package = Package(
.package(url: "https://github.com/apple/swift-collections", from: "1.1.0"),
.package(url: "https://github.com/pointfreeco/combine-schedulers", from: "1.0.2"),
.package(url: "https://github.com/pointfreeco/swift-case-paths", from: "1.5.4"),
.package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.1.0"),
.package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.2.0"),
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "1.3.2"),
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.4.0"),
.package(url: "https://github.com/pointfreeco/swift-identified-collections", from: "1.1.0"),
Expand Down
2 changes: 1 addition & 1 deletion [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let package = Package(
.package(url: "https://github.com/apple/swift-collections", from: "1.1.0"),
.package(url: "https://github.com/pointfreeco/combine-schedulers", from: "1.0.2"),
.package(url: "https://github.com/pointfreeco/swift-case-paths", from: "1.5.4"),
.package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.1.0"),
.package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.2.0"),
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "1.3.2"),
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.4.0"),
.package(url: "https://github.com/pointfreeco/swift-identified-collections", from: "1.1.0"),
Expand Down
4 changes: 2 additions & 2 deletions Sources/ComposableArchitecture/Effect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ extension Effect {

/// Wraps an asynchronous unit of work that can emit actions any number of times in an effect.
///
/// For example, if you had an async stream in a dependency client:
/// For example, if you had an async sequence in a dependency client:
///
/// ```swift
/// struct EventsClient {
/// var events: () -> AsyncStream<Event>
/// var events: () -> any AsyncSequence<Event, Never>
/// }
/// ```
///
Expand Down
7 changes: 0 additions & 7 deletions Sources/ComposableArchitecture/Internal/NavigationID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,3 @@ struct NavigationID: Hashable, @unchecked Sendable {
hasher.combine(self.tag)
}
}

@_spi(Internals) public struct AnyHashableSendable: Hashable, @unchecked Sendable {
@_spi(Internals) public let base: AnyHashable
init<Base: Hashable & Sendable>(_ base: Base) {
self.base = base
}
}
4 changes: 2 additions & 2 deletions Tests/ComposableArchitectureTests/FileStorageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ final class FileStorageTests: XCTestCase {
await Task.yield()
expectNoDifference(users, [.blob])

$users.withLock { $0 = [.blobJr] } // NB: Saved immediately
$users.withLock { $0 = [.blobSr] } // NB: Throttled for 1 second
await $users.withLock { $0 = [.blobJr] } // NB: Saved immediately
await $users.withLock { $0 = [.blobSr] } // NB: Throttled for 1 second
try FileManager.default.removeItem(at: .fileURL)
try await Task.sleep(nanoseconds: 1_200_000_000)
expectNoDifference(users, [.blob])
Expand Down
Loading