In my reducer switch I have it like...
enum WelcomeRequestId {}
switch action {
case .fetchContent:
return environment.welcomeScreenClient.fetchContent()
.receive(on: environment.main)
.catchToEffect(WelcomeScreenAction.contentResponse)
// .cancellable(id: WelcomeRequestId.self, cancelInFlight: true)
This builds.
But... if I uncomment the last line in this case I get a build error...
Type of expression is ambiguous without more context
In the auto complete it is showing the correct type so I'm not sure now what it is that I've done wrong.
Any ideas?
Thanks
Using types as cancel identifiers is a new feature that we still haven't cut a version for. In the meantime, you can use the older style:
struct WelcomeRequestId: Hashable {}
// And then:
.cancellable(id: WelcomeRequestId(), cancelInFlight: true)
We'll try to cut a new version soon, though!
1 Like
Ah ok, thanks.
I think maybe the example code might need to be updated...
import Combine
import ComposableArchitecture
import SwiftUI
private let readMe = """
This screen demonstrates how one can cancel in-flight effects in the Composable Architecture.
Use the stepper to count to a number, and then tap the "Number fact" button to fetch \
a random fact about that number using an API.
While the API request is in-flight, you can tap "Cancel" to cancel the effect and prevent \
it from feeding data back into the application. Interacting with the stepper while a \
request is in-flight will also cancel it.
"""
// MARK: - Demo app domain
struct EffectsCancellationState: Equatable {
var count = 0
var currentFact: String?
This file has been truncated. show original
This is example code on the main
branch, which we try to keep up-to-date with any changes on main
. You can check out the 0.34.0 version of this code here .
1 Like
Ah! I see.
I hadn't realised.
Thanks again for the help.
By the way, we just release 0.35.0 , so you can update to the new style today
1 Like