diff --git a/Package.swift b/Package.swift index 0ed615d..12d690d 100644 --- a/Package.swift +++ b/Package.swift @@ -1,15 +1,15 @@ -// swift-tools-version: 5.9 +// swift-tools-version: 6.0 import PackageDescription let package = Package( name: "OneWay", platforms: [ - .iOS(.v13), - .macOS(.v10_15), - .tvOS(.v13), + .iOS(.v16), + .macOS(.v13), + .tvOS(.v16), .visionOS(.v1), - .watchOS(.v6), + .watchOS(.v9), ], products: [ .library( @@ -53,10 +53,3 @@ let package = Package( ), ] ) - -//for target in package.targets { -// target.swiftSettings = target.swiftSettings ?? [] -// target.swiftSettings?.append( -// .enableExperimentalFeature("StrictConcurrency") -// ) -//} diff --git a/README.md b/README.md index 9999027..ca1d814 100644 --- a/README.md +++ b/README.md @@ -372,6 +372,7 @@ To learn how to use **OneWay** in more detail, go through the [documentation](ht | OneWay | Swift | Xcode | Platforms | |--------|-------|-------|-------------------------------------------------------------| +| 3.0 | 6.0 | 16.0 | iOS 16.0, macOS 13, tvOS 16.0, visionOS 1.0, watchOS 9.0 | | 2.0 | 5.9 | 15.0 | iOS 13.0, macOS 10.15, tvOS 13.0, visionOS 1.0, watchOS 6.0 | | 1.0 | 5.5 | 13.0 | iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0 | diff --git a/Sources/OneWay/AnyEffect.swift b/Sources/OneWay/AnyEffect.swift index cbc23d9..e7ebd15 100644 --- a/Sources/OneWay/AnyEffect.swift +++ b/Sources/OneWay/AnyEffect.swift @@ -75,6 +75,7 @@ public struct AnyEffect: Effect where Element: Sendable { /// - id: The effect's identifier. /// - seconds: The duration for which the effect should wait before sending an element. /// - Returns: A new effect that sends elements only after a specified time elapses. + @available(*, deprecated, renamed: "debounce(id:for:clock:)") public consuming func debounce( id: some EffectID, for seconds: Double @@ -133,7 +134,6 @@ public struct AnyEffect: Effect where Element: Sendable { /// - dueTime: The duration for which the effect should wait before sending an element. /// - clock: The clock used for measuring time intervals. /// - Returns: A new effect that sends elements only after a specified time elapses. - @available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *) public consuming func debounce( id: some EffectID, for dueTime: C.Instant.Duration, diff --git a/Tests/OneWayTests/EffectTests.swift b/Tests/OneWayTests/EffectTests.swift index 8f5063f..06f2fe8 100644 --- a/Tests/OneWayTests/EffectTests.swift +++ b/Tests/OneWayTests/EffectTests.swift @@ -9,7 +9,6 @@ import Clocks import OneWay import XCTest -@available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *) final class EffectTests: XCTestCase { enum Action: Sendable { case first diff --git a/Tests/OneWayTests/StoreTests.swift b/Tests/OneWayTests/StoreTests.swift index 7558fa7..d6a74cf 100644 --- a/Tests/OneWayTests/StoreTests.swift +++ b/Tests/OneWayTests/StoreTests.swift @@ -13,7 +13,6 @@ import OneWay import OneWayTesting import XCTest -@available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *) final class StoreTests: XCTestCase { private var sut: Store! private var clock: TestClock! @@ -159,37 +158,14 @@ final class StoreTests: XCTestCase { } func test_debounce() async { - for _ in 0..<5 { - try! await Task.sleep(nanoseconds: NSEC_PER_MSEC * 100) - await sut.send(.debouncedIncrement) - } - try! await Task.sleep(nanoseconds: NSEC_PER_MSEC * 550) - for _ in 0..<5 { - try! await Task.sleep(nanoseconds: NSEC_PER_MSEC * 100) - await sut.send(.debouncedIncrement) - } - try! await Task.sleep(nanoseconds: NSEC_PER_MSEC * 550) - - await sut.expect(\.count, 2) - - for _ in 0..<5 { - try! await Task.sleep(nanoseconds: NSEC_PER_MSEC * 100) - await sut.send(.debouncedIncrement) - } - try! await Task.sleep(nanoseconds: NSEC_PER_MSEC * 100) // 100ms < 500ms - - await sut.expect(\.count, 2, timeout: 0.1) - } - - func test_debounceWithClock() async { for _ in 0..<5 { await clock.advance(by: .seconds(10)) - await sut.send(.debouncedIncrementWithClock) + await sut.send(.debouncedIncrement) } await clock.advance(by: .seconds(100)) for _ in 0..<5 { await clock.advance(by: .seconds(10)) - await sut.send(.debouncedIncrementWithClock) + await sut.send(.debouncedIncrement) } await clock.advance(by: .seconds(100)) @@ -197,7 +173,7 @@ final class StoreTests: XCTestCase { for _ in 0..<5 { await clock.advance(by: .seconds(10)) - await sut.send(.debouncedIncrementWithClock) + await sut.send(.debouncedIncrement) } await clock.advance(by: .seconds(10)) // 10s < 100s @@ -205,37 +181,14 @@ final class StoreTests: XCTestCase { } func test_deboouncedSequence() async { - for _ in 0..<5 { - try! await Task.sleep(nanoseconds: NSEC_PER_MSEC * 100) - await sut.send(.debouncedSequence) - } - try! await Task.sleep(nanoseconds: NSEC_PER_MSEC * 550) - for _ in 0..<5 { - try! await Task.sleep(nanoseconds: NSEC_PER_MSEC * 100) - await sut.send(.debouncedSequence) - } - try! await Task.sleep(nanoseconds: NSEC_PER_MSEC * 550) - - await sut.expect(\.count, 10) - - for _ in 0..<5 { - try! await Task.sleep(nanoseconds: NSEC_PER_MSEC * 100) - await sut.send(.debouncedSequence) - } - try! await Task.sleep(nanoseconds: NSEC_PER_MSEC * 100) // 100ms < 500ms - - await sut.expect(\.count, 10, timeout: 0.1) - } - - func test_deboouncedSequenceWithClock() async { for _ in 0..<5 { await clock.advance(by: .seconds(10)) - await sut.send(.debouncedSequenceWithClock) + await sut.send(.debouncedSequence) } await clock.advance(by: .seconds(100)) for _ in 0..<5 { await clock.advance(by: .seconds(10)) - await sut.send(.debouncedSequenceWithClock) + await sut.send(.debouncedSequence) } await clock.advance(by: .seconds(100)) @@ -243,7 +196,7 @@ final class StoreTests: XCTestCase { for _ in 0..<5 { await clock.advance(by: .seconds(10)) - await sut.send(.debouncedSequenceWithClock) + await sut.send(.debouncedSequence) } await clock.advance(by: .seconds(10)) // 10s < 100s @@ -260,7 +213,6 @@ private struct TestPublisher: @unchecked Sendable { private let testPublisher = TestPublisher() #endif -@available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *) private struct TestReducer: Reducer { enum Action: Sendable { case increment @@ -271,9 +223,7 @@ private struct TestReducer: Reducer { case longTimeTask case cancelLongTimeTask case debouncedIncrement - case debouncedIncrementWithClock case debouncedSequence - case debouncedSequenceWithClock } struct State: Equatable { @@ -332,24 +282,10 @@ private struct TestReducer: Reducer { return .cancel(EffectID.longTimeTask) case .debouncedIncrement: - return .just(.increment) - .debounce(id: Debounce.increment, for: 0.5) - - case .debouncedIncrementWithClock: return .just(.increment) .debounce(id: Debounce.increment, for: .seconds(100), clock: clock) case .debouncedSequence: - return .sequence { send in - send(.increment) - send(.increment) - send(.increment) - send(.increment) - send(.increment) - } - .debounce(id: Debounce.incrementSequence, for: 0.5) - - case .debouncedSequenceWithClock: return .sequence { send in send(.increment) send(.increment)