ResultOperation

open class ResultOperation<Success, Failure> : AsynchronousOperation where Failure : Error

An AsynchronousOperation that produces a result once finished.

If a ResultOperation gets cancelled before being executed, no result will be produced by default.

  • Block executed after the operation is finished providing the final result (if any).

    Note

    onFinish and completionBlock call order is not guaranteed in any way.

    Declaration

    Swift

    public var onFinish: ((Result<Success, Failure>?) -> Void)?
  • The result produced by the operation.

    Declaration

    Swift

    public final private(set) var result: Result<Success, Failure>? { get set }
  • Finishes the operation with the produced result.

    Important

    You should never call this method outside the operation main execution scope.

    Declaration

    Swift

    public final func finish(with result: Result<Success, Failure>)
  • Cancels the operation with a failure.

    Declaration

    Swift

    open func cancel(with failure: Failure)
  • Declaration

    Swift

    public final override func finish()