Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Replacing with new version of trySetError and trySetResult #50

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Sources/ParseLiveQuery/Internal/BoltsHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ func objcTask<T where T: AnyObject>(task: Task<T>) -> BFTask {
}
return taskCompletionSource.task
}

func swiftTask(task: BFTask) -> Task<AnyObject> {
let taskCompletionSource = TaskCompletionSource<AnyObject>()
task.continueWithBlock { task in
if task.cancelled {
taskCompletionSource.tryCancel()
} else if let error = task.error where task.faulted {
taskCompletionSource.trySetError(error)
taskCompletionSource.set(error: error)
} else if let result = task.result {
taskCompletionSource.trySetResult(result)
taskCompletionSource.set(result: result)
} else {
fatalError("Unknown task state")
}
return nil
}
return taskCompletionSource.task
}