Replies: 2 comments 10 replies
-
Hi @p4checo, unfortunately we cannot do that because it would be a breaking change for anyone using the dependencies library. Also, beyond that, it's a goal of this library to provide a base set of dependencies that nearly every application will need to make use of, such as schedulers. Can you describe more what is the exact problem you are having? Can you not disambiguate the And if this problem really is insurmountable without removing Combine schedulers, then you may have to fork this library to unblock you. |
Beta Was this translation helpful? Give feedback.
-
I was afraid you would say that, but I understand 🥲
Sure, apologies for not being clear from the start. Yes, we can easily disambiguate as you mention but the problem is that in the ReactiveSwift fork of TCA we've been defining the extension DependencyValues {
public var mainQueue: DateScheduler {
get { self[MainQueueKey.self] }
set { self[MainQueueKey.self] = newValue }
}
private enum MainQueueKey: DependencyKey {
static let liveValue = QueueScheduler.main as DateScheduler
static let testValue = UnimplementedScheduler() as DateScheduler
}
} However with the new standalone dependencies by default it will now use the one defined as final class ComposableArchitectureTests: XCTestCase {
func testScheduling() async {
struct Counter: ReducerProtocol {
typealias State = Int
enum Action: Equatable {
case incrAndSquareLater
case incrNow
case squareNow
}
@Dependency(\.mainQueue) var mainQueue
func reduce(into state: inout State, action: Action) -> EffectTask<Action> {
switch action {
case .incrAndSquareLater:
return .merge(
EffectTask(value: .incrNow)
.deferred(for: 2, scheduler: self.mainQueue), // compile error here
EffectTask(value: .squareNow)
.deferred(for: 1, scheduler: self.mainQueue), // compile error here
EffectTask(value: .squareNow)
.deferred(for: 2, scheduler: self.mainQueue) // compile error here
)
case .incrNow:
state += 1
return .none
case .squareNow:
state *= state
return .none
}
}
}
// (...)
}
Failing with the following error message:
Possible solutions:
Hope this made it a bit clearer. Do you have any other suggestion? I might be missing something or simply holding it wrong™ 😅
Yeah this is always an option, but I would like to avoid it if possible as it creates a new set of problems and increases the gap between both TCA forks 😐 |
Beta Was this translation helpful? Give feedback.
-
Hi @stephencelis @mbrandonw 👋🏼
I've been bringing the ReactiveSwift fork of TCA up to date with the latest upstream TCA changes, and while I think it's awesome that Dependencies are now on its own repo, the fact that
MainQueue
(andMainRunLoop
**) has been included (and thus CombineSchedulers) is causing some issues when integrating with the ReactiveSwift fork.The problem arises because ReactiveSwift uses its own scheduler types and protocols which are not compatible with CombineScheduler's (and Combine's). While this is isn't a problem in Linux due to the
#if canInport(Combine)
, it does create a conflict in Apple platforms which isn't easy to circumvent.My suggestion is then to move
MainQueue
(andMainRunLoop
**) back to the TCA repo as "internal" dependencies, effectively removing the dependency on CombineSchedulers from Dependencies. I also assume Clocks are the way forward so I expect the reliance on schedulers to be temporary anyway.What do you think? Thanks! 🙏🏼
Notes:
** We aren't using
MainRunLoop
in the ReactiveSwift fork, but for the sake of consistency it would make sense to migrate it as well since it also depends on CombienSchedulers.Beta Was this translation helpful? Give feedback.
All reactions