Using `cancellable` creates build error "Type of expression is ambiguous without more context"

In my reducer switch I have it like...

enum WelcomeRequestId {}

switch action {
case .fetchContent:
	return environment.welcomeScreenClient.fetchContent()
		.receive(on: environment.main)
//		.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?


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...

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. :smiley:

By the way, we just release 0.35.0, so you can update to the new style today :smile:

1 Like