Skip to content

Commit

Permalink
RxOptional 4.0.0 (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
freak4pc authored May 2, 2019
1 parent 1eee9e0 commit 48b78e8
Show file tree
Hide file tree
Showing 20 changed files with 128 additions and 279 deletions.
16 changes: 8 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
XCODE_TEST_REPORTS: /tmp/xcode-test-results
LANG: en_US.UTF-8
macos:
xcode: '10.0.0'
xcode: '10.2.0'
steps:
- checkout
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS $XCODE_TEST_REPORTS
Expand All @@ -25,20 +25,20 @@ jobs:
paths:
- Carthage
- run:
name: Test macOS, Swift 4
command: set -o pipefail && xcodebuild test SWIFT_VERSION=4.0 -scheme "RxOptional macOS" -project RxOptional.xcodeproj -sdk macosx -destination "arch=x86_64" | xcpretty -c -r html --output $XCODE_TEST_REPORTS/macOS_swift4.html
name: Test macOS, Swift 5
command: set -o pipefail && xcodebuild test SWIFT_VERSION=5.0 -scheme "RxOptional macOS" -project RxOptional.xcodeproj -sdk macosx -destination "arch=x86_64" | xcpretty -c -r html --output $XCODE_TEST_REPORTS/macOS_swift5.html
- run:
name: Test macOS, Swift 4.2
command: set -o pipefail && xcodebuild test SWIFT_VERSION=4.2 -scheme "RxOptional macOS" -project RxOptional.xcodeproj -sdk macosx -destination "arch=x86_64" | xcpretty -c -r html --output $XCODE_TEST_REPORTS/macOS_swift4_2.html
- run:
name: Test iOS, Swift 4
command: set -o pipefail && xcodebuild test SWIFT_VERSION=4.0 -scheme "RxOptional iOS" -project RxOptional.xcodeproj -sdk iphonesimulator -destination "name=iPhone X" | xcpretty -c -r html --output $XCODE_TEST_REPORTS/iOS_swift4.html
name: Test iOS, Swift 5
command: set -o pipefail && xcodebuild test SWIFT_VERSION=5.0 -scheme "RxOptional iOS" -project RxOptional.xcodeproj -sdk iphonesimulator -destination "name=iPhone X" | xcpretty -c -r html --output $XCODE_TEST_REPORTS/iOS_swift5.html
- run:
name: Test iOS, Swift 4.2
command: set -o pipefail && xcodebuild test SWIFT_VERSION=4.2 -scheme "RxOptional iOS" -project RxOptional.xcodeproj -sdk iphonesimulator -destination "name=iPhone X" | xcpretty -c -r html --output $XCODE_TEST_REPORTS/iOS_swift4.2.html
- run:
name: Test tvOS, Swift 4
command: set -o pipefail && xcodebuild test SWIFT_VERSION=4.0 -scheme "RxOptional tvOS" -project RxOptional.xcodeproj -sdk appletvsimulator -destination "name=Apple TV 4K (at 1080p)" | xcpretty -c -r html --output $XCODE_TEST_REPORTS/tvOS_swift4.html
name: Test tvOS, Swift 5
command: set -o pipefail && xcodebuild test SWIFT_VERSION=5.0 -scheme "RxOptional tvOS" -project RxOptional.xcodeproj -sdk appletvsimulator -destination "name=Apple TV 4K (at 1080p)" | xcpretty -c -r html --output $XCODE_TEST_REPORTS/tvOS_swift5.html
- run:
name: Test tvOS, Swift 4.2
command: set -o pipefail && xcodebuild test SWIFT_VERSION=4.2 -scheme "RxOptional tvOS" -project RxOptional.xcodeproj -sdk appletvsimulator -destination "name=Apple TV 4K (at 1080p)" | xcpretty -c -r html --output $XCODE_TEST_REPORTS/tvOS_swift4_2.html
Expand All @@ -51,7 +51,7 @@ jobs:
environment:
LANG: en_US.UTF-8
macos:
xcode: '10.0.0'
xcode: '10.2.0'
steps:
- checkout
- run:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# master

# 4.0.0

- Requires RxSwift 5 & Xcode 10.2.
- Minimum iOS deployment target is iOS 9.
- Update WatchOS deployment target to 3.0.

# 3.6.2
Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "ReactiveX/RxSwift" ~> 4.3.1
github "ReactiveX/RxSwift" ~> 5.0
6 changes: 3 additions & 3 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github "Quick/Nimble" "v7.3.1"
github "Quick/Quick" "v1.3.2"
github "ReactiveX/RxSwift" "4.4.0"
github "Quick/Nimble" "v8.0.1"
github "Quick/Quick" "v2.1.0"
github "ReactiveX/RxSwift" "5.0.1"
10 changes: 5 additions & 5 deletions RxOptional.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'RxOptional'
s.version = '3.6.2'
s.version = '4.0.0'
s.summary = 'RxSwift extensions for Swift optionals and Occupiable types'

s.description = <<-DESC
Expand All @@ -15,14 +15,14 @@ Pod::Spec.new do |s|
:tag => s.version.to_s
}

s.ios.deployment_target = '8.0'
s.ios.deployment_target = '9.0'
s.osx.deployment_target = '10.10'
s.watchos.deployment_target = '2.0'
s.watchos.deployment_target = '3.0'
s.tvos.deployment_target = '9.0'

s.source_files = 'Source/*.swift'

s.dependency 'RxSwift', '~> 4.0'
s.dependency 'RxCocoa', '~> 4.0'
s.dependency 'RxSwift', '~> 5'
s.dependency 'RxCocoa', '~> 5'
s.frameworks = 'Foundation'
end
177 changes: 41 additions & 136 deletions RxOptional.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
18 changes: 9 additions & 9 deletions Source/Observable+Occupiable.swift
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import Foundation
import RxSwift

public extension ObservableType where E: Occupiable {
public extension ObservableType where Element: Occupiable {
/**
Filter out empty occupiable elements.

- returns: `Observable` of source `Observable`'s occupiable elements, with empty occupiable elements filtered out.
*/

func filterEmpty() -> Observable<E> {
return self.flatMap { element -> Observable<E> in
func filterEmpty() -> Observable<Element> {
return self.flatMap { element -> Observable<Element> in
guard element.isNotEmpty else {
return Observable<E>.empty()
return Observable<Element>.empty()
}
return Observable<E>.just(element)
return Observable<Element>.just(element)
}
}

Expand All @@ -25,12 +25,12 @@ public extension ObservableType where E: Occupiable {
- returns: `Observable` of the source `Observable`'s occupiable elements, with empty occupiable elements replaced by the handler's returned non-empty occupiable elements.
*/

func catchOnEmpty(_ handler: @escaping () throws -> Observable<E>) -> Observable<E> {
return self.flatMap { element -> Observable<E> in
func catchOnEmpty(_ handler: @escaping () throws -> Observable<Element>) -> Observable<Element> {
return self.flatMap { element -> Observable<Element> in
guard element.isNotEmpty else {
return try handler()
}
return Observable<E>.just(element)
return Observable<Element>.just(element)
}
}

Expand All @@ -44,7 +44,7 @@ public extension ObservableType where E: Occupiable {
- returns: original source `Observable` of non-empty occupiable elements if it contains no empty occupiable elements.
*/

func errorOnEmpty(_ error: Error = RxOptionalError.emptyOccupiable(E.self)) -> Observable<E> {
func errorOnEmpty(_ error: Error = RxOptionalError.emptyOccupiable(Element.self)) -> Observable<Element> {
return self.map { element in
guard element.isNotEmpty else {
throw error
Expand Down
28 changes: 14 additions & 14 deletions Source/Observable+Optional.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import RxSwift
// Some code originally from here: https://github.com/artsy/eidolon/blob/24e36a69bbafb4ef6dbe4d98b575ceb4e1d8345f/Kiosk/Observable%2BOperators.swift#L42-L62
// Credit to Artsy and @ashfurrow

public extension ObservableType where E: OptionalType {
public extension ObservableType where Element: OptionalType {
/**
Unwraps and filters out `nil` elements.

- returns: `Observable` of source `Observable`'s elements, with `nil` elements filtered out.
*/

func filterNil() -> Observable<E.Wrapped> {
return self.flatMap { element -> Observable<E.Wrapped> in
func filterNil() -> Observable<Element.Wrapped> {
return self.flatMap { element -> Observable<Element.Wrapped> in
guard let value = element.value else {
return Observable<E.Wrapped>.empty()
return Observable<Element.Wrapped>.empty()
}
return Observable<E.Wrapped>.just(value)
return Observable<Element.Wrapped>.just(value)
}
}

Expand All @@ -28,7 +28,7 @@ public extension ObservableType where E: OptionalType {
- returns: `Observable` of source `Observable`'s elements, with `nil` elements filtered out.
*/

func filterNilKeepOptional() -> Observable<E> {
func filterNilKeepOptional() -> Observable<Element> {
return self.filter { element -> Bool in
return element.value != nil
}
Expand All @@ -44,8 +44,8 @@ public extension ObservableType where E: OptionalType {
- returns: original source `Observable` of non-empty elements if it contains no empty elements.
*/

func errorOnNil(_ error: Error = RxOptionalError.foundNilWhileUnwrappingOptional(E.self)) -> Observable<E.Wrapped> {
return self.map { element -> E.Wrapped in
func errorOnNil(_ error: Error = RxOptionalError.foundNilWhileUnwrappingOptional(Element.self)) -> Observable<Element.Wrapped> {
return self.map { element -> Element.Wrapped in
guard let value = element.value else {
throw error
}
Expand All @@ -61,8 +61,8 @@ public extension ObservableType where E: OptionalType {
- returns: `Observable` of the source `Observable`'s unwrapped elements, with `nil` elements replaced by `valueOnNil`.
*/

func replaceNilWith(_ valueOnNil: E.Wrapped) -> Observable<E.Wrapped> {
return self.map { element -> E.Wrapped in
func replaceNilWith(_ valueOnNil: Element.Wrapped) -> Observable<Element.Wrapped> {
return self.map { element -> Element.Wrapped in
guard let value = element.value else {
return valueOnNil
}
Expand All @@ -78,18 +78,18 @@ public extension ObservableType where E: OptionalType {
- returns: `Observable` of the source `Observable`'s unwrapped elements, with `nil` elements replaced by the handler's returned non-`nil` elements.
*/

func catchOnNil(_ handler: @escaping () throws -> Observable<E.Wrapped>) -> Observable<E.Wrapped> {
return self.flatMap { element -> Observable<E.Wrapped> in
func catchOnNil(_ handler: @escaping () throws -> Observable<Element.Wrapped>) -> Observable<Element.Wrapped> {
return self.flatMap { element -> Observable<Element.Wrapped> in
guard let value = element.value else {
return try handler()
}
return Observable<E.Wrapped>.just(value)
return Observable<Element.Wrapped>.just(value)
}
}
}

#if !swift(>=3.3) || (swift(>=4.0) && !swift(>=4.1))
public extension ObservableType where E: OptionalType, E.Wrapped: Equatable {
public extension ObservableType where Element: OptionalType, Element.Wrapped: Equatable {
/**
Returns an observable sequence that contains only distinct contiguous elements according to equality operator.

Expand Down
16 changes: 8 additions & 8 deletions Source/SharedSequence+Occupiable.swift
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import Foundation
import RxCocoa

public extension SharedSequenceConvertibleType where E: Occupiable {
public extension SharedSequenceConvertibleType where Element: Occupiable {
/**
Filters out empty elements.

- returns: `Driver` of source `Driver`'s elements, with empty elements filtered out.
*/

func filterEmpty() -> SharedSequence<SharingStrategy,E> {
return flatMap { element -> SharedSequence<SharingStrategy,E> in
func filterEmpty() -> SharedSequence<SharingStrategy, Element> {
return flatMap { element -> SharedSequence<SharingStrategy, Element> in
guard element.isNotEmpty else {
return SharedSequence<SharingStrategy,E>.empty()
return SharedSequence<SharingStrategy, Element>.empty()
}
return SharedSequence<SharingStrategy,E>.just(element)
return SharedSequence<SharingStrategy, Element>.just(element)
}
}

Expand All @@ -25,12 +25,12 @@ public extension SharedSequenceConvertibleType where E: Occupiable {
- returns: `Driver` of the source `Driver`'s elements, with empty elements replaced by the handler's returned non-empty elements.
*/

func catchOnEmpty(_ handler: @escaping () -> SharedSequence<SharingStrategy,E>) -> SharedSequence<SharingStrategy,E> {
return flatMap { element -> SharedSequence<SharingStrategy,E> in
func catchOnEmpty(_ handler: @escaping () -> SharedSequence<SharingStrategy, Element>) -> SharedSequence<SharingStrategy, Element> {
return flatMap { element -> SharedSequence<SharingStrategy, Element> in
guard element.isNotEmpty else {
return handler()
}
return SharedSequence<SharingStrategy,E>.just(element)
return SharedSequence<SharingStrategy, Element>.just(element)
}
}
}
Loading

0 comments on commit 48b78e8

Please sign in to comment.