In Bolts, how do you use continueWith() vs continueWithTask()?

你说的曾经没有我的故事 提交于 2019-12-04 05:18:23

When you have helper methods that return a Task object, you cannot use continueWith() or onSuccess() because the Bolts code won't treat it as a Task and wait for its execution. It would treat the Task as a simple data result.

Basically, this won't work, because the resulting task of this chain is a 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>>

But this will work and the chain will return a 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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!