Type Aliases

The following type aliases are available globally.

  • Type for mock delay randomizer.

    Declaration

    Swift

    public typealias MockDelayRange = (min: TimeInterval, max: TimeInterval)

    Parameters

    min

    The lower bound of interval.

    max

    The upper bound of interval.

  • Hook type for beforeAllRequestsCallback queue property

    Declaration

    Swift

    public typealias BeforeQueueStartCallbackType = () -> Void
  • Hook type for afterAllRequestsCallback queue property

    Declaration

    Swift

    public typealias AfterAllRequestsCallbackType = (_ hasError: Bool) -> Void

    Parameters

    hasError

    Passes a Boolean value which indicates if any of the request in queue has completed with error.

  • Hook type for beforeEachRequestCallback queue property

    Declaration

    Swift

    public typealias BeforeEachRequestCallbackType = (_ request: Request) -> Void

    Parameters

    request

    The actual Request instance.

  • Hook type for afterEachRequestCallback queue property

    Declaration

    Swift

    public typealias AfterEachRequestCallbackType = (
        _ request: Request,
        _ data: Data?,
        _ response: URLResponse?,
        _ error: Error?) -> Void

    Parameters

    request

    The actual Request instance.

    data

    The response data

    response

    The URLResponse

    error

    The network error (if any)

  • Type for reachability monitoring updates

    Declaration

    Swift

    public typealias ReachabilityUpdateClosureType = (_ status: ReachabilityState) -> Void

    Parameters

    status

    The new network state.

  • The Image type depending on platform: UIImage for iOS or NSImage for macOS.

    Declaration

    Swift

    public typealias ImageType = NSImage
  • The Image type depending on platform: UIImage for iOS or NSImage for macOS.

  • Callback type for image preprocess used in UIImageView|NSImage|WKInterfaceImage and Image (SwiftUI) helpers

    Declaration

    Swift

    public typealias ImagePreprocessType = (_ image: ImageType) -> (ImageType)

    Parameters

    image

    The downloaded image.

    Return Value

    The new transformed image.

  • Callback type for image downloaded event.

    Declaration

    Swift

    public typealias ImageOnFinishCallbackType = (_ image: ImageType?, _ error: TNError?) -> Void

    Parameters

    image

    The downloaded image.

    error

    A TNError object if it fails to download.

    Return Value

    The new transformed image.

  • Progress callback type

    Declaration

    Swift

    public typealias ProgressCallbackType = (_ bytesProcessed: Int,
                                             _ totalBytes: Int,
                                             _ progress: Float) -> Void

    Parameters

    bytesProcessed

    The total size of bytes sent/downloaded to/from server.

    totalBytes

    The total size of upload/download data.

    progress

    Download/Upload progress

  • Custom type for success data task.

    Declaration

    Swift

    public typealias SuccessCallback<T> = (_ object: T) -> Void

    Parameters

    object

    The object to be returned as T type.

  • Custom type for success data task without type.

    Declaration

    Swift

    public typealias SuccessCallbackWithoutType = () -> Void
  • Custom type for download success data task.

    Declaration

    Swift

    public typealias DownloadSuccessCallback = () -> Void
  • Custom type for failure data task. Failure callback (Obsolete).

    Declaration

    Swift

    public typealias FailureCallback = (_ error: TNError, _ data: Data?) -> Void

    Parameters

    error

    The the error that caused the request to fail.

    data

    The response data if any.

  • Custom type for failure data task without type.

    Declaration

    Swift

    public typealias FailureCallbackWithoutType = (TNError) -> Void

    Parameters

    error

    The the error that caused the request to fail.

  • Custom type for failure data task with custom type.

    Declaration

    Swift

    public typealias FailureCallbackWithType<T> = (_ object: T?, _ error: TNError) -> Void

    Parameters

    object

    The object to be returned as T type.

    error

    The the error that caused the request to fail.