You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
- 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?
The text was updated successfully, but these errors were encountered:
As far as I'm concerned, you use continueWith if you want to do something with the result of a task and return a value to be used by the next continuation block. For example, the previous task returns a string, you manipulate the string in continueWith and return the result. Then in the next block something is done with the manipulated string.
continueWithTask on the other side is used if you instead of returning a plain value, you want to return another task. Chaining another continueWith will get the result of the other task. Here is an example:
aFunctionWhichReturnsATaskOfInt().continueOnSuccessWith(){ aInt in
return result > 0
}.continueOnSuccessWithTask(){ aBool -> Task in
return anotherFunctionWhichReturnsATaskOfString(aBool: aBool)
}.continueOnSuccessWith(){ aString in
...
}
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 usecontinueWithTask
. 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.
vs
in the source code for
continueWith
it statescontinueWithTask
hasDoes this mean that the task returned by
continueWith
will have a completion/error state as soon as it is returned, while incontinueWithTask
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?The text was updated successfully, but these errors were encountered: