Back to Alamofire

DataResponsePublisher

docs/Structs/DataResponsePublisher.html

5.12.03.5 KB
Original Source

DataResponsePublisher

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
public struct DataResponsePublisher<Value> : Publisher where Value : Sendable

A Combine Publisher that publishes the DataResponse<Value, AFError> of the provided DataRequest.

`

                Output
                `

Declaration

Swift

public typealias Output = DataResponse<Value, AFError>

`

                Failure
                `

Declaration

Swift

public typealias Failure = Never

`

                init(_:queue:serializer:)
                `

Creates an instance which will serialize responses using the provided ResponseSerializer.

Declaration

Swift

public init<Serializer: ResponseSerializer>(_ request: DataRequest, queue: DispatchQueue, serializer: Serializer)
    where Value == Serializer.SerializedObject

Parameters

| request |

DataRequest for which to publish the response.

| | queue |

DispatchQueue on which the DataResponse value will be published. .main by default.

| | serializer |

ResponseSerializer used to produce the published DataResponse.

|

`

                init(_:queue:serializer:)
                `

Creates an instance which will serialize responses using the provided DataResponseSerializerProtocol.

Declaration

Swift

public init<Serializer: DataResponseSerializerProtocol>(_ request: DataRequest,
                                                        queue: DispatchQueue,
                                                        serializer: Serializer)
    where Value == Serializer.SerializedObject

Parameters

| request |

DataRequest for which to publish the response.

| | queue |

DispatchQueue on which the DataResponse value will be published. .main by default.

| | serializer |

DataResponseSerializerProtocol used to produce the published DataResponse.

|

`

                result()
                `

Publishes only the Result of the DataResponse value.

Declaration

Swift

public func result() -> AnyPublisher<Result<Value, AFError>, Never>

Return Value

The AnyPublisher publishing the Result<Value, AFError> value.

`

                value()
                `

Publishes the Result of the DataResponse as a single Value or fail with the AFError instance.

Declaration

Swift

public func value() -> AnyPublisher<Value, AFError>

Return Value

The AnyPublisher<Value, AFError> publishing the stream.

`

                receive(subscriber:)
                `

Declaration

Swift

public func receive<S>(subscriber: S) where S : Subscriber, S : Sendable, S.Failure == Never, S.Input == DataResponse<Value, AFError>

Available where Value == Data?

`

                init(_:queue:)
                `

Creates an instance which publishes a DataResponse<Data?, AFError> value without serialization.

Declaration

Swift

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
public init(_ request: DataRequest, queue: DispatchQueue)