AnyPublisher

public extension AnyPublisher where Output == Response, Failure == MoyaError
public extension AnyPublisher where Output == ProgressResponse, Failure == MoyaError

Extension for processing raw NSData generated by network access.

Available where Output == Response, Failure == MoyaError

  • Filters out responses that don’t fall within the given range, generating errors when others are encountered.

    Declaration

    Swift

    func filter<R>(statusCodes: R) -> AnyPublisher<Response, MoyaError> where R : RangeExpression, R.Bound == Int
  • Filters out responses that has the specified statusCode.

    Declaration

    Swift

    func filter(statusCode: Int) -> AnyPublisher<Response, MoyaError>
  • Filters out responses where statusCode falls within the range 200 - 299.

    Declaration

    Swift

    func filterSuccessfulStatusCodes() -> AnyPublisher<Response, MoyaError>
  • Filters out responses where statusCode falls within the range 200 - 399

    Declaration

    Swift

    func filterSuccessfulStatusAndRedirectCodes() -> AnyPublisher<Response, MoyaError>
  • Maps data received from the signal into an Image. If the conversion fails, the signal errors.

    Declaration

    Swift

    func mapImage() -> AnyPublisher<Image, MoyaError>
  • Maps data received from the signal into a JSON object. If the conversion fails, the signal errors.

    Declaration

    Swift

    func mapJSON(failsOnEmptyData: Bool = true) -> AnyPublisher<Any, MoyaError>
  • Maps received data at key path into a String. If the conversion fails, the signal errors.

    Declaration

    Swift

    func mapString(atKeyPath keyPath: String? = nil) -> AnyPublisher<String, MoyaError>
  • Maps received data at key path into a Decodable object. If the conversion fails, the signal errors.

    Declaration

    Swift

    func map<D>(_ type: D.Type, atKeyPath keyPath: String? = nil, using decoder: JSONDecoder = JSONDecoder(), failsOnEmptyData: Bool = true) -> AnyPublisher<D, MoyaError> where D : Decodable

Available where Output == ProgressResponse, Failure == MoyaError

  • Filter completed progress response and maps to actual response

    Declaration

    Swift

    func filterCompleted() -> AnyPublisher<Response, MoyaError>

    Return Value

    response associated with ProgressResponse object

  • Filter progress events of current ProgressResponse

    Declaration

    Swift

    func filterProgress() -> AnyPublisher<Double, MoyaError>

    Return Value

    observable of progress events