From 29a49abafb2045c8db4831cad2e21edffa640820 Mon Sep 17 00:00:00 2001 From: Otavio Cordeiro Date: Sat, 27 Feb 2021 07:23:46 +0100 Subject: [PATCH] Add .errorLoading --- Sources/PinboardKit/API/PinboardAPI.swift | 2 ++ Sources/PinboardKit/API/PinboardAPIEvent.swift | 1 + Sources/PinboardKit/NetworkClient/PinboardClient.swift | 4 ++++ Sources/PinboardKit/NetworkClient/PinboardClientEvent.swift | 1 + 4 files changed, 8 insertions(+) diff --git a/Sources/PinboardKit/API/PinboardAPI.swift b/Sources/PinboardKit/API/PinboardAPI.swift index c92c36f..064f407 100644 --- a/Sources/PinboardKit/API/PinboardAPI.swift +++ b/Sources/PinboardKit/API/PinboardAPI.swift @@ -33,6 +33,8 @@ public struct PinboardAPI { return .loading case .finishedLoading: return .finishedLoading + case .errorLoading: + return .errorLoading } } .eraseToAnyPublisher() diff --git a/Sources/PinboardKit/API/PinboardAPIEvent.swift b/Sources/PinboardKit/API/PinboardAPIEvent.swift index 157df60..759ac5d 100644 --- a/Sources/PinboardKit/API/PinboardAPIEvent.swift +++ b/Sources/PinboardKit/API/PinboardAPIEvent.swift @@ -3,4 +3,5 @@ import Foundation public enum PinboardAPIEvent { case loading case finishedLoading + case errorLoading } diff --git a/Sources/PinboardKit/NetworkClient/PinboardClient.swift b/Sources/PinboardKit/NetworkClient/PinboardClient.swift index 34c77ee..94526e3 100644 --- a/Sources/PinboardKit/NetworkClient/PinboardClient.swift +++ b/Sources/PinboardKit/NetworkClient/PinboardClient.swift @@ -53,6 +53,10 @@ struct PinboardClient { response: result.response ) } + .mapError{ error -> Error in + eventSubject.send(.errorLoading) + return error + } .receive(on: DispatchQueue.main) .eraseToAnyPublisher() } diff --git a/Sources/PinboardKit/NetworkClient/PinboardClientEvent.swift b/Sources/PinboardKit/NetworkClient/PinboardClientEvent.swift index 9956ad7..c0165f1 100644 --- a/Sources/PinboardKit/NetworkClient/PinboardClientEvent.swift +++ b/Sources/PinboardKit/NetworkClient/PinboardClientEvent.swift @@ -3,4 +3,5 @@ import Foundation enum PinboardClientEvent { case loading case finishedLoading + case errorLoading }