Skip to content

Difference between continueWith and continueWithTask not clear in the documentation #53

Description

@ir-fuel

The docs state:

If you return any object from continueWith function - this will become a result of the new function. And if you want to call into more tasks and return those results - you can use continueWithTask. This gives you an ability to chain more asynchronous work together.

For me the difference is absolutely not clear, especially since both have exactly the same signature in Swift.

    @discardableResult
    public func continueWith<S>(_ executor: Executor = .default, continuation: @escaping ((Task) throws -> S)) -> Task<S> {

vs

    @discardableResult
    public func continueWithTask<S>(_ executor: Executor = .default, continuation: @escaping ((Task) throws -> Task<S>)) -> Task<S> {

in the source code for continueWith it states

- returns: A task that will be completed with a result from a given closure.

continueWithTask has

- returns: A task that will be completed when a task returned from a closure is completed.

Does this mean that the task returned by continueWith will have a completion/error state as soon as it is returned, while in continueWithTask it might not immediately be the case?

And in the second case, is the task that will be completed not simply the task returned by the closure?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions