TransferState

public enum TransferState<Progress, Value>

Represents a transfer state, either loading or finished. This is useful to represent a transfer state in percentage or bytes uploaded for example.

It is recommended to define a typealias corresponding to your use case that specify at least the Progress type, for example:

typealias DownloadState<Value> = TransferState<Double, Value>

or

typealias DownloadState<Value> = TransferState<(uploadedBytes: UInt64, totalBytes: UInt64)?, Value>

Nothing prevents you to also include the Value type in the typealias, if possible for your use case.

  • Represents a loading state.

    Declaration

    Swift

    case loading(Progress)
  • Represents a finished state.

    Declaration

    Swift

    case finished(Value)
  • Map a TransferState finishing with one Value into another, mapping it with the given closure.

    Declaration

    Swift

    public func map<Mapped>(_ mapper: (Value) -> Mapped) -> TransferState<Progress, Mapped>

    Parameters

    mapper

    Mapper closure how to map the initial value to the mapped value.

    Return Value

    A TransferState with the mapped value as mapped by the given closure.