Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only send error event if not from cancelling the task #21

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
Expand All @@ -12,6 +13,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Changed

- Only emit error events that are not from canceling the task. [#21](https://github.com/RxSwiftCommunity/RxKingfisher/pull/21)

## [1.0.0] - 2019-08-07

### Changed
Expand All @@ -28,6 +31,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [0.5.0] - 2019-03-01

### Changed

- Minimum deployment targets are now iOS 10, tvOS 10 and macOS 10.12.
- Minimum Swift Version is 4.2.
- RxKingfisher now works with, and requires, Kingfisher 5
Expand All @@ -41,6 +45,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [0.2.0] - 2018-07-28

### Changed

- Use `Binder` instead of `AnyObserver`.

## [0.1.1] - 2018-05-21
Expand Down
8 changes: 8 additions & 0 deletions RxKingfisher.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
78A52EF4209EF9C6002E26D2 /* Kingfisher.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 78A52EF1209EF9C6002E26D2 /* Kingfisher.framework */; };
78A52EFE209EF9E2002E26D2 /* RxSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 78A52EFB209EF9E2002E26D2 /* RxSwift.framework */; };
78A52F00209EF9E2002E26D2 /* Kingfisher.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 78A52EFD209EF9E2002E26D2 /* Kingfisher.framework */; };
85EFD9692470DAFC000AECB3 /* KingfisherErrorExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85EFD9682470DAFC000AECB3 /* KingfisherErrorExtensions.swift */; };
85EFD96A2470DB06000AECB3 /* KingfisherErrorExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85EFD9682470DAFC000AECB3 /* KingfisherErrorExtensions.swift */; };
85EFD96B2470DB06000AECB3 /* KingfisherErrorExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85EFD9682470DAFC000AECB3 /* KingfisherErrorExtensions.swift */; };
8933C78E1EB5B82C000D00A4 /* RxKingfisherTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8933C7891EB5B82A000D00A4 /* RxKingfisherTests.swift */; };
8933C78F1EB5B82C000D00A4 /* RxKingfisherTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8933C7891EB5B82A000D00A4 /* RxKingfisherTests.swift */; };
8933C7901EB5B82D000D00A4 /* RxKingfisherTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8933C7891EB5B82A000D00A4 /* RxKingfisherTests.swift */; };
Expand Down Expand Up @@ -77,6 +80,7 @@
78A52EFB209EF9E2002E26D2 /* RxSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxSwift.framework; path = Carthage/Build/tvOS/RxSwift.framework; sourceTree = "<group>"; };
78A52EFC209EF9E2002E26D2 /* RxCocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxCocoa.framework; path = Carthage/Build/tvOS/RxCocoa.framework; sourceTree = "<group>"; };
78A52EFD209EF9E2002E26D2 /* Kingfisher.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Kingfisher.framework; path = Carthage/Build/tvOS/Kingfisher.framework; sourceTree = "<group>"; };
85EFD9682470DAFC000AECB3 /* KingfisherErrorExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KingfisherErrorExtensions.swift; sourceTree = "<group>"; };
8933C7891EB5B82A000D00A4 /* RxKingfisherTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxKingfisherTests.swift; sourceTree = "<group>"; };
AD2FAA261CD0B6D800659CF4 /* RxKingfisher.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = RxKingfisher.plist; sourceTree = "<group>"; };
AD2FAA281CD0B6E100659CF4 /* RxKingfisherTests.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = RxKingfisherTests.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -199,6 +203,7 @@
children = (
78A52EDB209EF999002E26D2 /* Kingfisher+Rx.swift */,
78A52EDA209EF999002E26D2 /* KingfisherManager+Rx.swift */,
85EFD9682470DAFC000AECB3 /* KingfisherErrorExtensions.swift */,
);
path = Sources;
sourceTree = "<group>";
Expand Down Expand Up @@ -478,6 +483,7 @@
files = (
78A52EE4209EF999002E26D2 /* Kingfisher+Rx.swift in Sources */,
78A52EE0209EF999002E26D2 /* KingfisherManager+Rx.swift in Sources */,
85EFD9692470DAFC000AECB3 /* KingfisherErrorExtensions.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -495,6 +501,7 @@
files = (
78A52EE7209EF999002E26D2 /* Kingfisher+Rx.swift in Sources */,
78A52EE3209EF999002E26D2 /* KingfisherManager+Rx.swift in Sources */,
85EFD96A2470DB06000AECB3 /* KingfisherErrorExtensions.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -504,6 +511,7 @@
files = (
78A52EE5209EF999002E26D2 /* Kingfisher+Rx.swift in Sources */,
78A52EE1209EF999002E26D2 /* KingfisherManager+Rx.swift in Sources */,
85EFD96B2470DB06000AECB3 /* KingfisherErrorExtensions.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
4 changes: 3 additions & 1 deletion Sources/Kingfisher+Rx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ extension Reactive where Base == KingfisherWrapper<ImageView> {
case .success(let value):
single(.success(value.image))
case .failure(let error):
single(.error(error))
if !error.isTaskCancelledError {
single(.error(error))
}
}
}

Expand Down
11 changes: 11 additions & 0 deletions Sources/KingfisherErrorExtensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Kingfisher

extension KingfisherError {
var isTaskCancelledError: Bool {
if case .requestError(reason: .taskCancelled) = self {
return true
} else {
return false
}
}
}
4 changes: 3 additions & 1 deletion Sources/KingfisherManager+Rx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ extension Reactive where Base == KingfisherManager {
case .success(let value):
single(.success(value.image))
case .failure(let error):
single(.error(error))
if !error.isTaskCancelledError {
single(.error(error))
}
Comment on lines 21 to +24
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just do case .failure(let error) where !error.isTaskCancelledError

}
}

Expand Down