ActionStatus

public enum ActionStatus<ErrorType> : Equatable where ErrorType : Equatable, ErrorType : Error

ActionStatus is a helpful enum which can be used to describe the state of a long running action such as; submitting a form, manipulating data, running migrations, executing API requests etc.

An example of what this could look like being used.

struct AppState: Equatable {
    var migrationStatus: ActionStatus<MigrationError> = .idle
}
  • Action is in an idle state and hasn’t yet started.

    Declaration

    Swift

    case idle
  • Action is in a loading state.

    Declaration

    Swift

    case loading
  • Action has been successfully completed.

    Declaration

    Swift

    case complete
  • Action has failed.

    Declaration

    Swift

    case failed(ErrorType)

Helpers

  • Indicates whether ActionStatus is in an idle state.

    Declaration

    Swift

    public var isIdle: Bool { get }
  • Indicates whether ActionStatus is in a loading state.

    Declaration

    Swift

    public var isLoading: Bool { get }
  • Indicates whether ActionStatus is in a complete state.

    Declaration

    Swift

    public var isComplete: Bool { get }
  • Indicates whether ActionStatus is in a failed state.

    Declaration

    Swift

    public var isFailed: Bool { get }
  • Convenience accessor to the error if the status is in a failed state.

    Declaration

    Swift

    public var error: ErrorType? { get }