Skip to content
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
7 changes: 4 additions & 3 deletions Examples/MotionManager/MotionManager/MotionManagerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ struct AppView_Previews: PreviewProvider {
userAcceleration: .init(x: -cos(-3 * t), y: sin(2 * t), z: -cos(t))
)
)
}
.eraseToEffect()
},
}
.setFailureType(to: MotionClient.Error.self)
.eraseToEffect()
},
startDeviceMotionUpdates: { _ in .fireAndForget { isStarted = true } },
stopDeviceMotionUpdates: { _ in .fireAndForget { isStarted = false } }
)
Expand Down
7 changes: 5 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,21 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/pointfreeco/swift-case-paths", from: "0.1.1")
.package(url: "https://github.com/pointfreeco/combine-schedulers", from: "0.1.0"),
.package(url: "https://github.com/pointfreeco/swift-case-paths", from: "0.1.1"),
],
targets: [
.target(
name: "ComposableArchitecture",
dependencies: [
"CasePaths"
"CasePaths",
"CombineSchedulers",
]
),
.testTarget(
name: "ComposableArchitectureTests",
dependencies: [
"CombineSchedulers",
"ComposableArchitecture",
]
),
Expand Down
28 changes: 7 additions & 21 deletions Sources/ComposableArchitecture/Effects/Timer.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Combine
import Foundation
import CombineSchedulers

extension Effect {
extension Effect where Failure == Never {
/// Returns an effect that repeatedly emits the current time of the given
/// scheduler on the given interval.
///
Expand Down Expand Up @@ -35,24 +35,10 @@ extension Effect {
options: S.SchedulerOptions? = nil
) -> Effect where S: Scheduler, S.SchedulerTimeType == Output {

Deferred { () -> Publishers.HandleEvents<PassthroughSubject<Output, Failure>> in
let subject = PassthroughSubject<S.SchedulerTimeType, Failure>()

let cancellable = scheduler.schedule(
after: scheduler.now.advanced(by: interval),
interval: interval,
tolerance: tolerance ?? .seconds(.max),
options: options
) {
subject.send(scheduler.now)
}

return subject.handleEvents(
receiveCompletion: { _ in cancellable.cancel() },
receiveCancel: cancellable.cancel
)
}
.eraseToEffect()
.cancellable(id: id)
Publishers.Timer(every: interval, tolerance: tolerance, scheduler: scheduler, options: options)
.autoconnect()
.setFailureType(to: Failure.self)
.eraseToEffect()
.cancellable(id: id)
}
}
1 change: 1 addition & 0 deletions Sources/ComposableArchitecture/Internal/Exports.swift
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@_exported import CasePaths
@_exported import CombineSchedulers
99 changes: 0 additions & 99 deletions Sources/ComposableArchitecture/Scheduling/AnyScheduler.swift

This file was deleted.

135 changes: 0 additions & 135 deletions Sources/ComposableArchitecture/Scheduling/TestScheduler.swift

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Combine
import CombineSchedulers
import ComposableArchitecture
import XCTest

Expand Down
1 change: 1 addition & 0 deletions Tests/ComposableArchitectureTests/ReducerTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Combine
import CombineSchedulers
import ComposableArchitecture
import XCTest
import os.signpost
Expand Down
Loading