Completing

public protocol Completing : CompletionController

A protocol for objects that can eventually complete with value

  • isComplete Extension method

    Shorthand property that returns true if Completing is complete

    Declaration

    Swift

    var isComplete: Bool { get }
  • success Extension method

    Shorthand property that returns success if Completing is completed with success or nil otherwise

    Declaration

    Swift

    var success: Success? { get }
  • failure Extension method

    Shorthand property that returns failure value if Completing is completed with failure or nil otherwise

    Declaration

    Swift

    var failure: Swift.Error? { get }
  • onComplete(executor:_:) Extension method

    Performs block when completion value. This method is method is less preferable then onComplete(context: ...).

    Declaration

    Swift

    @discardableResult
    func onComplete(
      executor: Executor = .primary,
      _ block: @escaping (Fallible<Success>) -> Void
      ) -> Self

    Parameters

    executor

    to call block on

    block

    block to call on completion

  • onSuccess(executor:_:) Extension method

    Performs block when competion becomes available.

    Declaration

    Swift

    @discardableResult
    func onSuccess(
      executor: Executor = .primary,
      _ block: @escaping (Success) -> Void
      ) -> Self
  • onFailure(executor:_:) Extension method

    Performs block when failure becomes available.

    Declaration

    Swift

    @discardableResult
    func onFailure(
      executor: Executor = .primary,
      _ block: @escaping (Swift.Error) -> Void
      ) -> Self
  • Performs block when completion value. This method is suitable for applying completion to context.

    Declaration

    Swift

    @discardableResult
    func onComplete<C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      _ block: @escaping (C, Fallible<Success>) -> Void
      ) -> Self

    Parameters

    context

    to complete on

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    block

    block to call on completion

  • Performs block when completion becomes available.

    Declaration

    Swift

    @discardableResult
    func onSuccess<C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      _ block: @escaping (C, Success) -> Void
      ) -> Self
  • Performs block when failure becomes available.

    Declaration

    Swift

    @discardableResult
    func onFailure<C: ExecutionContext>(
      context: C, executor: Executor? = nil,
      _ block: @escaping (C, Swift.Error) -> Void
      ) -> Self
  • wait() Extension method

    Waits for future to complete and returns completion value. Waits forever

    Declaration

    Swift

    func wait() -> Fallible<Success>
  • wait(timeout:) Extension method

    Waits for future to complete and returns completion value

    Declaration

    Swift

    func wait(timeout: DispatchTime) -> Fallible<Success>?

    Parameters

    timeout

    DispatchTime to wait completion for

    Return Value

    completion value or nil if Future did not complete in specified timeout

  • wait(wallTimeout:) Extension method

    Waits for future to complete and returns completion value

    Declaration

    Swift

    func wait(wallTimeout: DispatchWallTime) -> Fallible<Success>?

    Parameters

    wallTimeout

    DispatchWallTime to wait completion for

    Return Value

    completion value or nil if Future did not complete in specified timeout

  • wait(nanoseconds:) Extension method

    Waits for future to complete and returns completion value

    Declaration

    Swift

    func wait(nanoseconds: Int) -> Fallible<Success>?

    Parameters

    nanoseconds

    to wait completion for

    Return Value

    completion value or nil if Future did not complete in specified timeout

  • wait(milliseconds:) Extension method

    Waits for future to complete and returns completion value

    Declaration

    Swift

    func wait(milliseconds: Int) -> Fallible<Success>?

    Parameters

    milliseconds

    to wait completion for

    Return Value

    completion value or nil if Future did not complete in specified timeout

  • wait(microseconds:) Extension method

    Waits for future to complete and returns completion value

    Declaration

    Swift

    func wait(microseconds: Int) -> Fallible<Success>?

    Parameters

    microseconds

    to wait completion for

    Return Value

    completion value or nil if Future did not complete in specified timeout

  • wait(seconds:) Extension method

    Waits for future to complete and returns completion value

    Declaration

    Swift

    func wait(seconds: Double) -> Fallible<Success>?

    Parameters

    seconds

    to wait completion for

    Return Value

    completion value or nil if Future did not complete in specified timeout

  • Transforms the Completing to a Future with transformation (Fallible<Success>) -> T.

    Declaration

    Swift

    func mapCompletion<T>(
      executor: Executor = .primary,
      pure: Bool = true,
      _ transform: @escaping (_ completion: Fallible<Success>) throws -> T
      ) -> Future<T>

    Parameters

    executor

    to perform transform on

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    completion

    of the Completing

    Return Value

    Future that will complete with transformed value

  • Transforms the Completing to a Future with transformation (Fallible<Success>) -> Completing.

    Declaration

    Swift

    func flatMapCompletion<T: Completing>(
      executor: Executor = .primary,
      pure: Bool = true,
      _ transform: @escaping (_ completion: Fallible<Success>) throws -> T
      ) -> Future<T.Success>

    Parameters

    executor

    to perform transform on

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    completion

    of the Completing

    Return Value

    Future that will complete with completion of returned Completing

  • Transforms the Completing to a Channel with transformation (Fallible<Success>) -> Completing&Updating.

    Declaration

    Swift

    func flatMapCompletion<T: Completing&Updating>(
      executor: Executor = .primary,
      pure: Bool = true,
      _ transform: @escaping (_ completion: Fallible<Success>) throws -> T
      ) -> Channel<T.Update, T.Success>

    Parameters

    executor

    to perform transform on

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    completion

    of the Completing

    Return Value

    Channel that will complete with completion of returned Completing&Updating

  • mapSuccess(executor:pure:_:) Extension method

    Transforms the Completing to a Future with transformation (Success) -> T. Failure of the Completing will be the fail of the returned Future.

    Declaration

    Swift

    func mapSuccess<T>(
      executor: Executor = .primary,
      pure: Bool = true,
      _ transform: @escaping (_ success: Success) throws -> T
      ) -> Future<T>

    Parameters

    executor

    to perform transform on

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    success

    of the Completing

    Return Value

    Future that will complete with transformed value

  • Transforms the Completing to a Future with transformation (Success) -> Completing. Failure of the Completing will be the fail of the returned Future.

    Declaration

    Swift

    func flatMapSuccess<T: Completing>(
      executor: Executor = .primary,
      pure: Bool = true,
      _ transform: @escaping (_ success: Success) throws -> T
      ) -> Future<T.Success>

    Parameters

    executor

    to perform transform on

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    success

    of the Completing

    Return Value

    Future that will complete with completion of returned Completing

  • Transforms the Completing to a Channel with transformation (Success) -> Completing&Updating. Failure of the Completing will be the fail of the returned Channel.

    Declaration

    Swift

    func flatMapSuccess<T: Completing&Updating>(
      executor: Executor = .primary,
      pure: Bool = true,
      _ transform: @escaping (_ success: Success) throws -> T
      ) -> Channel<T.Update, T.Success>

    Parameters

    executor

    to perform transform on

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    success

    of the Completing

    Return Value

    Channel that will complete with completion of returned Completing&Updating

  • recover(with:) Extension method

    Recovers from all failures with specified success. Success of the Completing will be the success of the returned Future.

    Declaration

    Swift

    func recover(with success: Success) -> Future<Success>

    Parameters

    success

    to recover with.

    Return Value

    Future that will always succeed

  • recover(from:with:) Extension method

    Recovers from errors equal to a specified error with specified success.

    Declaration

    Swift

    func recover<E: Swift.Error>(
      from specificError: E,
      with success: Success
      ) -> Future<Success> where E: Equatable

    Parameters

    specificError

    error to recover from

    success

    to recover with.

    Return Value

    Future that will

    • succeed when the Completing succeeds
    • or if failure of the Compleing is equal to the specified error will succeed with specified success
    • or will fail with a failure of Completing

  • recover(executor:pure:_:) Extension method

    Transforms the Completing to a Future with transformation (Error) -> Success. Success of the Completing will be the success of the returned Future.

    Declaration

    Swift

    func recover(
      executor: Executor = .primary,
      pure: Bool = true,
      _ transform: @escaping (_ failure: Swift.Error) throws -> Success
      ) -> Future<Success>

    Parameters

    executor

    to perform transform on

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    failure

    of the Completing

    Return Value

    Future that will complete with transformed value

  • Transforms the Completing to a Future with transformation (E) -> Success. Success of the Completing will be the success of the returned Future.

    Declaration

    Swift

    func recover<E: Swift.Error>(
      from specificError: E,
      executor: Executor = .primary,
      pure: Bool = true,
      _ transform: @escaping (_ failure: E) throws -> Success
      ) -> Future<Success> where E: Equatable

    Parameters

    executor

    to perform transform on

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    failure

    of the Completing

    Return Value

    Future that will complete with transformed value

  • Transforms the Completing to a Future with transformation (E) -> Completing. Success of the Completing will be the success of the returned Future.

    Declaration

    Swift

    func flatRecover<T: Completing>(
      executor: Executor = .primary,
      pure: Bool = true,
      _ transform: @escaping (_ failure: Swift.Error) throws -> T
      ) -> Future<Success> where T.Success == Success

    Parameters

    executor

    to perform transform on

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    failure

    of the Completing

    Return Value

    Future that will complete with transformed value

  • Transforms the Completing to a Future with transformation (E) -> Completing. Success of the Completing will be the success of the returned Future.

    Declaration

    Swift

    func flatRecover<T: Completing, E: Swift.Error>(
      from specificError: E,
      executor: Executor = .primary,
      pure: Bool = true,
      _ transform: @escaping (_ failure: E) throws -> T
      ) -> Future<Success> where T.Success == Success, E: Equatable

    Parameters

    specificError

    error to recover from

    executor

    to perform transform on

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    failure

    of the Completing

    Return Value

    Future that will complete with transformed value

  • Transforms the Completing to a Future with transformation (Fallible<Success>) -> T.

    Declaration

    Swift

    func mapCompletion<Transformed, C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      pure: Bool = true,
      _ transform: @escaping (C, Fallible<Success>) throws -> Transformed
      ) -> Future<Transformed>

    Parameters

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    completion

    of the Completing

    Return Value

    Future that will complete with transformed value

  • Transforms the Completing to a Future with transformation (Fallible<Success>) -> Completing.

    Declaration

    Swift

    func flatMapCompletion<T: Completing, C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      pure: Bool = true,
      _ transform: @escaping (C, Fallible<Success>) throws -> T
      ) -> Future<T.Success>

    Parameters

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    completion

    of the Completing

    Return Value

    Future that will complete with completion of returned Completing

  • Transforms the Completing to a Channel with transformation (Fallible<Success>) -> Completing&Updating.

    Declaration

    Swift

    func flatMapCompletion<T: Completing&Updating, C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      pure: Bool = true,
      _ transform: @escaping (C, Fallible<Success>) throws -> T
      ) -> Channel<T.Update, T.Success>

    Parameters

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    completion

    of the Completing

    Return Value

    Channel that will complete with completion of returned Completing&Updating

  • Transforms the Completing to a Future with transformation (Success) -> T. Failure of the Completing will be the fail of the returned Future.

    Declaration

    Swift

    func mapSuccess<Transformed, C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      pure: Bool = true,
      _ transform: @escaping (C, Success) throws -> Transformed
      ) -> Future<Transformed>

    Parameters

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    success

    of the Completing

    Return Value

    Future that will complete with transformed value

  • Transforms the Completing to a Future with transformation (Success) -> Completing. Failure of the Completing will be the fail of the returned Future.

    Declaration

    Swift

    func flatMapSuccess<T: Completing, C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      pure: Bool = true,
      _ transform: @escaping (C, Success) throws -> T
      ) -> Future<T.Success>

    Parameters

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    success

    of the Completing

    Return Value

    Future that will complete with completion of returned Completing

  • Transforms the Completing to a Channel with transformation (Success) -> Completing&Updating. Failure of the Completing will be the fail of the returned Channel.

    Declaration

    Swift

    func flatMapSuccess<T: Completing&Updating, C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      pure: Bool = true,
      _ transform: @escaping (C, Success) throws -> T
      ) -> Channel<T.Update, T.Success>

    Parameters

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    success

    of the Completing

    Return Value

    Channel that will complete with completion of returned Completing&Updating

  • Transforms the Completing to a Future with transformation (Error) -> Success. Success of the Completing will be the success of the returned Future.

    Declaration

    Swift

    func recover<C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      pure: Bool = true,
      _ transform: @escaping (C, Swift.Error) throws -> Success
      ) -> Future<Success>

    Parameters

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    failure

    of the Completing

    Return Value

    Future that will complete with transformed value

  • Transforms the Completing to a Future with transformation (E) -> Success. Success of the Completing will be the success of the returned Future.

    Declaration

    Swift

    func recover<E: Swift.Error, C: ExecutionContext>(
      from specificError: E,
      context: C,
      executor: Executor? = nil,
      pure: Bool = true,
      _ transform: @escaping (C, E) throws -> Success
      ) -> Future<Success> where E: Equatable

    Parameters

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    failure

    of the Completing

    Return Value

    Future that will complete with transformed value

  • Transforms the Completing to a Future with transformation (E) -> Completing. Success of the Completing will be the success of the returned Future.

    Declaration

    Swift

    func flatRecover<T: Completing, C: ExecutionContext>(
      context: C,
      executor: Executor? = nil,
      pure: Bool = true,
      _ transform: @escaping (C, Swift.Error) throws -> T
      ) -> Future<Success> where T.Success == Success

    Parameters

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    failure

    of the Completing

    Return Value

    Future that will complete with transformed value

  • Transforms the Completing to a Future with transformation (E) -> Completing. Success of the Completing will be the success of the returned Future.

    Declaration

    Swift

    func flatRecover<T: Completing, E: Swift.Error, C: ExecutionContext>(
      from specificError: E,
      context: C,
      executor: Executor? = nil,
      pure: Bool = true,
      _ transform: @escaping (C, Swift.Error) throws -> T
      ) -> Future<Success> where T.Success == Success, E: Equatable

    Parameters

    specificError

    error to recover from

    context

    ExectionContext to apply transformation in

    executor

    override of ExecutionContexts executor. Keep default value of the argument unless you need to override an executor provided by the context

    pure

    defines if the transfromation is pure. Pure transformations have no side effects:

    transform

    transformation to perform

    failure

    of the Completing

    Return Value

    Future that will complete with transformed value

  • Returns future that completes after a timeout after completion of self

    Declaration

    Swift

    func delayedCompletion(
      timeout: Double,
      on executor: Executor = .primary
      ) -> Future<Success>