Jef*_*sen 6 android bolts-framework
除了sync和async之外,他们的文档中的差异让我感到困惑.他们的github页面上的示例仍然看起来像是同步调用continuation.
continueWith()
Adds a synchronous continuation to this task, returning a new task that completes after the continuation has finished running.
continueWithTask()
Adds an asynchronous continuation to this task, returning a new task that completes after the task returned by the continuation has completed.
当您具有返回Task对象的辅助方法时,您将无法使用continueWith()或onSuccess()因为Bolts代码不会将其视为a Task并等待其执行。它将Task视为一个简单的数据结果。
基本上,这是行不通的,因为此链的最终任务是Task<Task<Void>>:
update().onSuccess(new Continuation<ParseObject, Task<Void>>()
{
public Task<Void> then(Task<ParseObject> task) throws Exception
{
return Task.delay(3000);
}
}) // this end returns a Task<Task<Void>>
Run Code Online (Sandbox Code Playgroud)
但这将起作用,并且链将返回Task<Void>:
update().onSuccessTask(new Continuation<ParseObject, Task<Void>>()
{
public Task<Void> then(Task<ParseObject> task) throws Exception
{
return Task.delay(3000);
}
}) // this end returns a Task<Void>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1805 次 |
| 最近记录: |