Cancel Combine Future

I want to use Combine.Future in an API I'm working on. I am trying to figure out how to wire up the cancellation of a future to the my async code. Consider the following code:

    func solveComplexProblem(for input: SomeInput) -> Combine.Future<SomeOutput, Error> {
        let future = Combine.Future<SomeOutput, Error> { promise in
            // Here is my code to run my logic, which is cancellable, but -
            // How can I know when to cancel?
        }
        return future
    }

How do I know when the user cancelled the subscription so that I can cancel my internal operation?

2 Likes
Terms of Service

Privacy Policy

Cookie Policy